Standard library / sync/atomic

atomic.Int32.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 *Int32) Load() int32

Return Value

int32

Current value.

Working Example

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