Top "Thread-safety" questions

A piece of code is thread-safe if it only manipulates data structures in a way that allows consistent execution of this code by multiple threads.

Why we need Thread.MemoryBarrier()?

In "C# 4 in a Nutshell", the author shows that this class can write 0 sometimes without MemoryBarrier, though I can't reproduce …

c# .net multithreading thread-safety memory-barriers
AtomicInteger and volatile

I know volatile allows for visibility, AtomicInteger allows for atomicity. So if I use a volatile AtomicInteger, does it mean …

java multithreading thread-safety atomic volatile
Is the += operator thread-safe in Python?

I want to create a non-thread-safe chunk of code for experimentation, and those are the functions that 2 threads are going …

python thread-safety increment
Is the max thread limit actually a non-relevant issue for Python / Linux?

The current Python application that I'm working on has a need to utilize 1000+ threads (Pythons threading module). Not that any …

python multithreading thread-safety threadpool python-multithreading
Is MemoryCache.Set() thread-safe?

The MSDN documentation for MemoryCache.Set unfortunately doesn’t state explicitly whether it is thread-safe or not. Is it safe …

c# thread-safety memorycache
ConcurrentHashMap: avoid extra object creation with "putIfAbsent"?

I am aggregating multiple values for keys in a multi-threaded environment. The keys are not known in advance. I thought …

java synchronization thread-safety concurrenthashmap
Is unique_ptr thread safe?

Is unique_ptr thread safe? Is it impossible for the code below to print same number twice? #include <memory&…

c++ multithreading c++11 thread-safety unique-ptr
Is using std::deque or std::priority_queue thread-safe?

Possible Duplicates: Is the C++ STL std::set thread-safe? Thread safety for STL queue I'm guessing it isn't, I just …

c++ stl thread-safety priority-queue deque
How to implement a unmanaged thread-safe collection when I get this error: <mutex> is not supported when compiling with /clr

I have a C++ application which consists of unmanaged C++, managed C++ and c#. In the unmanaged part I'm trying …

c++ multithreading thread-safety c++-cli mutex
How to correctly read an Interlocked.Increment'ed int field?

Suppose I have a non-volatile int field, and a thread which Interlocked.Increments it. Can another thread safely read this …

c# .net multithreading thread-safety