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.

What does threadsafe mean?

Recently I tried to Access a textbox from a thread (other than the UI thread) and an exception was thrown. …

multithreading thread-safety definition
efficient thread-safe singleton in C++

The usual pattern for a singleton class is something like static Foo &getInst() { static Foo *inst = NULL; if(inst == …

c++ singleton thread-safety pthreads
iphone ios running in separate thread

What is the best way to run code on a separate thread? Is it: [NSThread detachNewThreadSelector: @selector(doStuff) toTarget:self …

iphone multithreading ios thread-safety
How to create a thread/Task with a continuous loop?

I am looking for the correct way/structure to create a loop in a Thread/Task... The reason for this …

c# .net multithreading thread-safety multitasking
What's the best way of implementing a thread-safe Dictionary?

I was able to implement a thread-safe Dictionary in C# by deriving from IDictionary and defining a private SyncRoot object: …

c# .net thread-safety collections
Queue.Queue vs. collections.deque

I need a queue which multiple threads can put stuff into, and multiple threads may read from. Python has at …

python thread-safety queue
Is local static variable initialization thread-safe in C++11?

I know this is an often asked question, but as there are so many variants, I'd like to re-state it, …

c++ thread-safety c++11
Are non-synchronised static methods thread safe if they don't modify static class variables?

I was wondering if you have a static method that is not synchronised, but does not modify any static variables …

java multithreading concurrency static thread-safety
Difference between -pthread and -lpthread while compiling

What is the difference between gcc -pthread and gcc -lpthread which is used while compiling multithreaded programs?

multithreading gcc thread-safety pthreads compiler-flags