#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 threads[10]; for (int i = 0; i < 10; ++i) { threads[i] = thread(Thread(i)); } // and join them cout << "Joining..." << endl; for (int i = 0; i < 10; ++i) { threads[i].join(); } cout << "Done!" << endl; }