Tag

sync.Once

0 views collected around this technical thread.

Go Programming World
Go Programming World
Nov 25, 2024 · Backend Development

Understanding Go's singleflight: Request Merging, Implementation and Use Cases

singleflight, a Go concurrency primitive from the x/sync package, merges duplicate in‑flight requests to reduce server load, with detailed usage examples, source code analysis, and discussion of its differences from sync.Once and typical application scenarios such as cache‑penetration, remote calls, and task deduplication.

CacheConcurrencyGo
0 likes · 26 min read
Understanding Go's singleflight: Request Merging, Implementation and Use Cases
FunTester
FunTester
Jun 22, 2022 · Backend Development

Implementing Go's sync.Once Behavior in Java Using ReentrantLock

This article explains the Go sync.Once primitive, demonstrates its one‑time execution with concurrent goroutines, and shows how to recreate the same functionality in Java by using a static collection and ReentrantLock to ensure a block of code runs only once across multiple threads.

ConcurrencyGoJava
0 likes · 5 min read
Implementing Go's sync.Once Behavior in Java Using ReentrantLock
Tencent Cloud Developer
Tencent Cloud Developer
Mar 30, 2022 · Backend Development

Go High-Performance Programming: Concurrency Optimization Techniques

This article, the second in a Go high‑performance series, details concurrency optimizations including lock‑free data structures versus locked lists, sharding and RWMutex to cut lock contention, controlling goroutine creation with pooling, using sync.Once for cheap one‑time initialization, and employing sync.Cond for efficient goroutine notification.

BenchmarkConcurrencyGo
0 likes · 30 min read
Go High-Performance Programming: Concurrency Optimization Techniques
360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
Oct 21, 2021 · Backend Development

Mastering sync.Once in Go: Thread‑Safe Singleton Patterns Explained

This article explains Go's sync.Once primitive, compares it with init, details various singleton implementations—including lazy, eager, and double‑checked locking—and provides practical code examples and a deep dive into its source implementation for thread‑safe one‑time initialization.

ConcurrencyGoLazy Initialization
0 likes · 7 min read
Mastering sync.Once in Go: Thread‑Safe Singleton Patterns Explained