When /MT, /MTd, /MD, or /MDd is used, the following thread-safety rules are in effect:
The container classes are vector, deque, list, queue, stack , priority_queue, valarray, map, multimap, set, multiset, basic_string, bitset.
For reads to the same object, the object is thread safe for reading in the following scenarios:
- From one thread at a time when no writers on other threads.
- From many threads at a time when no writers on other threads.
For writes to the same object, the object is thread safe for writing from one thread when no readers on other threads
For reads to different objects of the same class, the object is thread safe for reading in the following scenarios:
- From one thread at a time.
- From one thread at a time when no writers on other threads.
- From many threads at a time.
- From many threads at a time when no writers on other threads.
For writes to different objects of the same class, the object is thread safe for writing in the following scenarios:
- From one thread when no readers on other threads.
- From many threads.
For example, given objects A and B of the same class, it is safe if object A is being written in thread 1 and B is being read in thread 2.
Partager