I need to make a program run just one copy of it using Mutex.
But I coudn't find anything on using Mutex in c++.

What system and compiler are you using? On Linux/Unix, there is a man page that gives details. Also, are you using pthreads (POSIX threads), or other threading API's?

Threading facilities can be found under Boost.Thread. These are essentially the libraries that will form the basis for the upcoming threading standard libraries in C++0x, so better get used to those functions/classes for now, until the standard ones come out. And they are cross-platform, so it doesn't matter much whether you are using Windows or Linux (except that performance of certain things are different from platform to platform because they have different kernel implementations).

You will find examples, on the link, on how to use mutexes.

What system and compiler are you using? On Linux/Unix, there is a man page that gives details. Also, are you using pthreads (POSIX threads), or other threading API's?

Well..I'm on Windows and use Visual Studio 08.
I've tried #include <pthreads> but it didn't work at all.

I've just started studing Win Api so I need a bit guidance here.

C++ did not added any multi-thread support in their language, instead of other languages like Java (which is far younger than C/C++ and has been in the beginning of the multi-thread era).

C++0x, the next revision of C++, will add thread support as a standard, so every compiler that will respect the new standard will support multi-threading.

This site provides a implementation of the upcoming multi-thread support in C++0x. It is not free (unfortunately), but it illustrates my point: http://www.stdthread.co.uk/

Windows does not support POSIX threads (pthreads), if I correctly remember my multi-thread assignments at the unversity.

Windows does not support POSIX threads (pthreads), if I correctly remember my multi-thread assignments at the unversity.

The "standard" Windows API's don't support POSIX threads and most other POSIX API's, but they are available for VC++, and I have used them extensively in the past for cross-platform development. Unfortunately, the biggest problem is that VC++ is not particularly standards compliant. For ANSI/ISO C++ standards compliance, the GNU compiler suite is still amongst the best. There are proprietary compilers from Intel and others that are as good, or possibly better, but they are quite costly and don't run on all available platforms, unlike GNU.

This article has been dead for over six months. Start a new discussion instead.