Standard library / sync/atomic

atomic.Uintptr.Store()

Atomically replace the current value. Other shared data needs its own synchronization protocol. Expected stdout: '15\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Uintptr) Store(val uintptr)

Parameters & Attributes

NameTypeDescription
valuintptrValue to store; context values should be request-scoped.

Working Example

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