#include <iostream>
#include <thread>
void print_message(std::string message, int count) {
for (int i = 0; i < count; i++) {
std::cout << message << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}
int main() {
std::string message1 = "Hello from thread 1!";
std::string message2 = "Hello from thread 2!";
std::thread t1(print_message, message1,5);
std::thread t2(print_message, message2,8);
t1.join();
t2.join();
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: