Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the C++ standard library thread safe? [duplicate]

Tags:

c++

std

Possible Duplicate:
Do I need to protect read access to an STL container in a multithreading environment?

I am using the C++ standard library which comes with (Linux) GCC or (Windows) VC.

Can anyone please say clearly whether or not this library is thread safe?

like image 833
User7723337 Avatar asked Sep 17 '25 03:09

User7723337


1 Answers

"Thread safe" is not a clearly-defined boolean property of a library. Some things can be done concurrently and others cannot.

Almost certainly if you were to ask a more detailed question specifying what it is you want to do, the answer would be "no, it is not thread-safe". But only almost.

If by "thread-safe" you mean something like the difference between Vector and ArrayList in Java, then C++ standard containers are non-thread-safe.

like image 158
Steve Jessop Avatar answered Sep 18 '25 17:09

Steve Jessop