std::thread
and friends in MinGW. Since I will probably use them a lot, I wrote a small header file which does the work for you. It is available on github as a gist : https://gist.github.com/1154023Since I believe people are too lazy to click links, and also because I want my blog to appear to have a lot of code in it, you will also find it just below:
/* Only use the code below if we have GCC with no support for GNU * threads */ #if !defined(_GLIBCXX_HAS_GTHREADS) && defined(__GNUG__) /* The boost thread library is used as a replacement for the * standard thread library. We'll consider it to be fully * compatible with the missing library. See http://www.open-std.org/ * ...jtc1/sc22/wg21/docs/papers/2008/n2497.html */ #include <boost/thread/thread.hpp> #include <boost/thread/mutex.hpp> #include <boost/thread/recursive_mutex.hpp> #include <boost/thread/locks.hpp> #include <boost/thread/condition_variable.hpp> /* Only classes are copied. Use boost directly or a real standard * library if you want free functions. */ namespace std { using boost::thread; using boost::mutex; using boost::timed_mutex; using boost::recursive_mutex; using boost::recursive_timed_mutex; using boost::lock_guard; using boost::unique_lock; using boost::condition_variable; using boost::condition_variable_any; } #endif /* Crippled GCC */
You may want to follow me on twitter.