Untitled
Anonymous
c_cpp
03/07/2025 6:58 AM
704 B
17
Indexable
#include <iostream>
#include <thread>
void function1() {
for (int i = 0; i < 200; i++)
std::cout << "+";
}
void function2() {
for (int i = 0; i < 200; i++)
std::cout << "-";
}
int main() {
std::thread t1(function1);
std::thread t2(function2);
std::thread::id t1_id = t1.get_id();
std::thread::id t2_id = t2.get_id();
std::cout << "ID of thread 1: " << t1_id << std::endl;
std::cout << "ID of thread 2: " << t2_id << std::endl;
t1.join();
t2.join();
return 0;
}
Editor is loading...
Leave a Comment