Skip to content
SP StackPractices

Tag: thread-safety

4 resources tagged with "thread-safety" on StackPractices.

Use Concurrent Data Structures for Thread-Safe Collections

How to safely share collections between threads using blocking queues, concurrent maps, copy-on-write lists, and atomic counters in Java, Python, and C++.

Coordinate Concurrent Tasks with Communicating Sequential Processes (CSP)

How to structure concurrent programs using channels, select statements, and goroutines for safe communication without shared mutable state in Go, Rust, and JavaScript.

Coordinate Shared Access with Locks, Mutexes, and Semaphores

How to prevent race conditions in concurrent programs using mutexes, read-write locks, semaphores, and atomic operations in Java, Python, and C++.

Ensure a Single Instance with the Singleton Pattern

How to guarantee exactly one instance of a class exists in an application using lazy initialization, thread-safe creation, and registry-based singletons.