#include #include using namespace std; class Thread { public: Thread(int i) : id(i) {}; Thread(const Thread& other) : id(other.id) {}; void operator()() { cout << "thread " << id << " is operating" << endl; } private: const int id; }; int main() { // fork off some threads thread t1(Thread(1)); thread t2(Thread(2)); thread t3(Thread(3)); thread t4(Thread(4)); // and join them cout << "Joining..." << endl; t1.join(); t2.join(); t3.join(); t4.join(); cout << "Done!" << endl; }