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

How similar is C++ concurrency API to Java

 
Cristina Yenyxe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

My question is basically the subject. I've used the Threading API in Java in several projects and then another one for C++ was announced, and it looked really similar (also the ones in other languages). What are the most important differences between them? Do you make any parallelism in your book? Not that I consider it the most important thing, but it could make the API easier to understand for people in my situation.

Greetings and thanks in advance,
Cristina
 
Anthony Aj Williams
author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cristina Yenyxe wrote:My question is basically the subject. I've used the Threading API in Java in several projects and then another one for C++ was announced, and it looked really similar (also the ones in other languages). What are the most important differences between them? Do you make any parallelism in your book? Not that I consider it the most important thing, but it could make the API easier to understand for people in my situation.


One of the appendices has a comparison table which relates the C++0x concurrency facilities to others, including the Java Threading API. To a large extent the differences are just syntactic rather than semantic.

The most obvious differences are that a new thread is started immediately when you pass the thread function to the std::thread constructor, rather than waiting for you to call Start(), and that you can pass any callable object or function to the std::thread constructor rather than having to derive a new class from Runnable.

One other noticable difference is that in Java you can use synchronized on any object; in C++0x you must explicitly provide a mutex object for locking.
 
Cristina Yenyxe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So learning how to use it should not be too complicated Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic