Portable C++ multi-threading. C++11, C++14, C++17.
2026-02-18
Written by: tdtc
A note to MinGW users: not supported—they may or may not work.
#include <boost/thread.hpp>
#include <boost/chrono.hpp>
#include <iostream>
void wait(int seconds)
{
boost::this_thread::sleep_for(boost::chrono::seconds{ seconds });
}
void thread()
{
for (int i = 0; i < 5; ++i)
{
wait(1);
std::cout << i << std::endl;
}
}
int main()
{
boost::thread t{ thread };
t.join();
}