Does Microsoft's STL container class implement thread security?

Source: Internet
Author: User
Tags microsoft c
STL container classes thread safe (Microsoft C ++ implementation )?

Answer from msdn:

The container classes are vector, deque, list, queue, stack, priority_queue, valarray, MAP, hash_map, multimap, hash_multimap, set, hash_set, Multiset, hash_multiset, basic_string, and bitset.

A single object is thread safe for reading from multiple threads. For example, given an object A, it is safe to read a from thread 1 and from thread 2 simultaneously.

If a single object is being written to by one thread, then all reads and writes to that object on the same or other threads must be protected. for example, given an object A, if thread 1 is writing to A, then thread 2 must be prevented from reading from or writing to.

it is safe to read and write to one instance of a type even if another thread is reading or writing to a different instance of the same type. for example, given objects A and B of the same type, it is safe if A is being written in thread 1 and B is being read in thread 2.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.