Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java vs C++ concurrency

 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anthony Aj Williams
author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic