| Author |
Java vs C++ concurrency
|
Tina Smith
Ranch Hand
Joined: Jul 21, 2011
Posts: 154
|
|
What's different about threading/concurrency in C++11 vs previous versions?
Is there any functionality that Java or C++ provides over the other as far as concurrency is concerned?
Which, in your opinion, is easier/better to use?
|
Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
|
 |
Anthony Aj Williams
author
Ranch Hand
Joined: Jun 10, 2011
Posts: 56
|
|
Tina Smith wrote:What's different about threading/concurrency in C++11 vs previous versions?
Prior to C++11, standard C++ didn't acknowledge the existence of concurrency, so any threading facilities provided were implementation-specific extensions.
In C++11, not only is there a multithreading-aware memory model, but the standard library now has the basic threading facilities --- mutexes, condition variables, and threads --- as well as some more advanced ones --- futures, promises, and async tasks.
Tina Smith wrote:Is there any functionality that Java or C++ provides over the other as far as concurrency is concerned?
Which, in your opinion, is easier/better to use?
The Java standard library provides facilities such as containers designed for concurrent access which are not part of the standard C++ library, but must be obtained from third parties or written yourself.
I prefer the way that C++ handles threading to the Java way, but a large part of that is due to the difference in structure between the languages. C++11 has lambdas, where Java only has inner classes, and C++ has the concept of "callable objects", whereas in Java you have to derive from an interface and implement a method.
|
Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/
just::thread C++11 thread library http://www.stdthread.co.uk
Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
|
 |
 |
|
|
subject: Java vs C++ concurrency
|
|
|