views:

176

answers:

4

I have come across many ad hoc implementations of thread class in C++, but why is there no standard library thread class like the one in Java? The one that I generally use in C++ is http://www.linuxdocs.org/HOWTOs/C++Programming-HOWTO-24.html

+12  A: 

std::thread will be standardized in C++0x, and many compilers already support it.

It is perhaps more ambitious than your cited example as construction/destruction signifies initiation/joining of thread execution.

Here's another article.

Potatoswatter
And `boost::thread` is the next best thing.
GMan
Excellent! Interesting name to the standard :)
srikfreak
The name of the standard will probably be C++11 when it is formally adopted. I've been trying this out using g++ 4.4.
Fred Larson
+8  A: 

Until C++0x arrives, I recommend using the Boost Thread class, which is about as close to a standard as we have for the kind of Thread class you're after.

Eli Courtwright
+1  A: 

For some more info on how to use std::thread see ...

std::threadhttp://www.justsoftwaresolutions.co.uk/threading/multithreading-in-c++0x-part-1-starting-threads.html

You might want to do a test with your compiler to see if it supports it. If not until then use one of the other libs.

Romain Hippeau
+2  A: 

C++ was invented in 1979. I don't think the notion of threads was really widespread at that time. (While there were multi-user and multi-process OSes back then, they were all very peculiar in their own ways. For example, it took until 1995 for pthreads to be standardised.)

crazyscot