Multithreading

An example that demonstrates how to create and manage threads.

cppCopy code#include <iostream>
#include <thread>

void printMessage() {
std::cout &lt;&lt; "Hello from thread!" &lt;&lt; std::endl;
} int main() {
std::thread t(printMessage);
t.join(); // Wait for the thread to finish
return 0;
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *