Standard library / sync/atomic

atomic.Int64.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 *Int64) Load() int64

Return Value

int64

Current value.

Working Example

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