I’m starting a series of hands on tutorials on concurrent programming using C++11. This first installment jumps right into “Hello Thread!” and the discussion of fork/join parallelism. I also sneaked in some lambdas and even one closure. Enjoy!
Follow @BartoszMilewski
August 29, 2011
C++11 Concurrency Tutorial
Posted by Bartosz Milewski under C++, Concurrency, Multithreading, Parallelism, Programming, Tutorial[17] Comments
August 30, 2011 at 11:06 am
Great video so far!
Caption under the video says the length is 50 minutes, but video appears unexpectedly cut off at 27 minutes.
Is this intended?
August 30, 2011 at 11:19 am
Yes, that’s it. I changed the description to approximately 30min 😉
August 30, 2011 at 8:38 pm
Great introductory video for threads and lambda functions. Thanks!
Something that immediately caught my attention was that the C++11 standard mentions that objects of type thread are not copyable, which would disallow push_back() into vector. But after some more reading I realized that the implementation must’ve moved the object instead of copying it (just like Anthony William’s boost::thread library).
August 31, 2011 at 12:39 am
Very informative video!
When can we expect the next part 🙂 ?
September 1, 2011 at 12:49 pm
Perhaps it should be pointed out that what you call ‘fork/join parallelism’ is something completely different form the ‘fork/join’ framework that is one of the big new things in Java 7. I’d hate to see people who see this video think ‘oh, is that all there is to it?’, while Java’s fork/join framework is actually a very interesting and useful (as well as cool) piece of technology to look into sometime.
September 1, 2011 at 2:18 pm
@Jan: Yes, the Java fork/join framework uses a more elaborated form of fork/join parallelism. In fact it’s an example of task-based parallelism in which fork doesn’t necessarily create a new thread. More about it in Doug Lea’s paper.
September 7, 2011 at 3:36 pm
Presume it’s only for demo purpose by passing a temporary thread object to vector’s push_back because the temporary thread may start running before it’s destroyed especially when complier does not optimise it away. So in real code, it must be a vector of smart pointers of threads.
September 7, 2011 at 3:46 pm
@Derek: The code is correct. My second tutorial explains why.
September 14, 2011 at 4:25 am
Hi,
Nice tutorial and nice video too, English isn’t my mother tongue but your voice is really perfect like a professional speaker!
I have tried your code on redhat 6.1 and g++ 4.4.5 without lambda support, so I made some change.
Is this still correct?
September 14, 2011 at 10:07 am
It looks correct to me.
November 14, 2011 at 4:24 am
Bartosz
Thank you for the series, I’ve started to watch them and will just use this post to point you to #4 where you’ve actually compared raw pointers for not move but ref based 🙂 version. Small omission.
Best regards
Andrzej
November 15, 2011 at 10:45 am
Andrzej, could you give me a little more context? There are already 9 tutorials, each of them about 1/2 hour. You can quote code if you surround it with the <pre> tags.
March 26, 2012 at 6:12 am
[…] These talks are available on MSDN. There is also a C++11 concurrency tutorial available on Bartosz Milewski’s blog, which is definitely worth listening to. Another useful source of information on concurrency in C++ […]
April 30, 2012 at 9:14 am
Hello Bartosz,
thank you very much for your concurrency tutorial wich gave me a very detailed outline of the new features regarding concurrency. Unfortunately the website the videos were uploaded to seems to have a bit of a problem with exceeded disk space… is it possible to share those via a different platform?
Best regards,
xmoex
April 30, 2012 at 4:22 pm
The tutorials moved to youtube
May 14, 2012 at 12:15 pm
I am working through the tutorials and sometimes have a hard time reading the screen. Could you document the options you used in your Makefile on Linux? Thank you.
June 28, 2016 at 3:11 am
[…] These talks are available on MSDN. There is also a C++11 concurrency tutorial available on Bartosz Milewski’s blog, which is definitely worth listening to. Another useful source of information on concurrency in C++ […]