Standard library / sync/atomic

atomic.Uint32.Load()

Atomically read the current value. Use atomic access consistently for a concurrently shared location. Expected stdout: '12\n12\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Uint32) Load() uint32

Return Value

uint32

Current value.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync/atomic")
func main() { var x atomic.Uint32; x.Store(12); fmt.Println(x.Load()); fmt.Println(x.Load()) }
Go Reference