I keep on hearing about concurrent programing every where. Can you guys throw some light on what it’s and how c++ new standards facilitate doing the same?
I keep on hearing about concurrent programing every where. Can you guys throw some
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Concurrency is about your code doing multiple things at the same time. This is typically done with explicit ‘threads’, but there are other possibilities. For example, if you use OpenMP directives in your code then a compiler that supports OpenMP will automatically generate threads for you.
Thread is short for ‘thread of execution’. In a single-threaded C++ program, execution starts at main(), and then proceeds in a sequential fashion. In a multi-threaded program, the first thread starts at main, but additional threads may be started by the application which start at a user-specified function. These then run concurrently, or in parallel with the original thread.
In C++0x threads are started using the
std::threadclass:The new C++0x standard also supports:
std::atomic<>class template,std::mutex,std::recursive_mutex, etc.)std::lock_guard<>,std::unique_lock<>)std::lockandstd::try_lockfunctions to manage acquiring multiple locks at the same time without risking deadlockstd::condition_variable,std::condition_variable_any)thread_localkeyword to declare thread-local dataI gave a more detailed overview of the new C++0x thread library in my article on devx.com: Simpler Multithreading in C++0x
I write about multithreading and concurrency in C++ on my blog. I’m also writing a book on the topic: C++ Concurrency in Action.