#include <iostream>
#include <thread>
void threadFunction(int id) {
std::cout << "Thread " << id << " is running." << std::endl;
}
int main() {
const int numThreads = 4;
std::thread threads[numThreads];
for (int i = 0; i < numThreads; i++) {
threads[i] = std::thread(threadFunction, i);
}
for (int i = 0; i < numThreads; i++) {
threads[i].join();
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dGhyZWFkPgoKdm9pZCB0aHJlYWRGdW5jdGlvbihpbnQgaWQpIHsKCXN0ZDo6Y291dCA8PCAiVGhyZWFkICIgPDwgaWQgPDwgIiBpcyBydW5uaW5nLiIgPDwgc3RkOjplbmRsOwp9CgppbnQgbWFpbigpIHsKCWNvbnN0IGludCBudW1UaHJlYWRzID0gNDsKCXN0ZDo6dGhyZWFkIHRocmVhZHNbbnVtVGhyZWFkc107CgoJZm9yIChpbnQgaSA9IDA7IGkgPCBudW1UaHJlYWRzOyBpKyspIHsKCQl0aHJlYWRzW2ldID0gc3RkOjp0aHJlYWQodGhyZWFkRnVuY3Rpb24sIGkpOwoJfQoKCWZvciAoaW50IGkgPSAwOyBpIDwgbnVtVGhyZWFkczsgaSsrKSB7CgkJdGhyZWFkc1tpXS5qb2luKCk7Cgl9CgoJcmV0dXJuIDA7Cn0=