views:

162

answers:

4

I want to implement threading in c++.I am using visual stdio2008 and wish to implement threading using pthreads.can any one guide me about pthreads and also about there implementations in vs2008.Thanking in anticipation

+9  A: 

Why do you want to use a plain C API (pthreads) usually used in *nix (pthreads) use in C++ on Windows? Any other reason than ... Whatever.

Use boost.thread. It uses windows threads on windows, pthread on posix platforms. It works well, and is portable.

If you really want to use pthread, you will use something like Microsoft Windows Services for UNIX. Never tried that one, though.

gimpf
I second this. boost.thread is a good API and quite similar to the C++0x std::thread API.My experience is that for utility you'll end up building an abstraction similar to boost::thread, but boost::thread is already built.
Rick
+1  A: 

ptheads is a POSIX term and are not usually available on windows.
If you want to create threads in windows in C/C++ the easiest way to go is to use _beginthread from the C Runtime Library or simply CreateThread from Win32

shoosh
+5  A: 

Download it here: http://sourceware.org/pthreads-win32/

Here is a tutorial: https://computing.llnl.gov/tutorials/pthreads/

Bastien Léonard
I second that, perfectly answers the question. But I somehow think that whoever has to ask "how do I use pthreads on Windows?" should really not use them.
gimpf
A: 

Not to leave you with a "read the f-ing book" answer, but I found "Windows via C/C++" by Richter and Nasarre to be a great overview of the Windows API. All of Chapters 6,7,8, and 9 in the most recent edition are about threads. Considering there are 4 chapters about threads in this book, I think the topic is pretty well fleshed out.

JohnG