Standard library / sync/atomic
atomic.LoadUintptr()
Atomically read the current value. Use atomic access consistently for a concurrently shared location. Raw pointer APIs require correctly aligned storage; prefer the corresponding typed atomic in new code. Expected stdout: '12\n12\n'.
Formal Syntax & Structure
go syntaxgo
func LoadUintptr(addr *uintptr) (val uintptr)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| addr | *uintptr | Pointer to the shared variable; satisfy architecture alignment requirements and use atomic access consistently. |
Return Value
(val uintptr)
Current value.
Working Example
Example Snippetgo
package main
import ( "fmt" "sync/atomic")
func main() { x := new(uintptr) atomic.StoreUintptr(x, 12) fmt.Println(atomic.LoadUintptr(x)) fmt.Println(atomic.LoadUintptr(x))}