#include #include #include #include #include A::A () : _t ([] () { { std::ostringstream oss; oss << "Starting thread " << std::this_thread::get_id () << std::endl; std::cout << oss.str() << std::flush; } std::this_thread::sleep_for (std::chrono::milliseconds(std::rand() % 100 * 10)); { std::ostringstream oss; oss << "Thread " << std::this_thread::get_id () << " finished" << std::endl; std::cout << oss.str() << std::flush; } }) { } A::~A () { _t.join (); }