#include<thread> #include<iostream> using namespace std; void print() { //printing frm thread for (int i = 10; i < 20; i++) { cout <<"thread"<< i << endl; } } void main() { thread t(print);//creating a thread instance for (int i = 1; i <10; i++) { cout << "Main" << i << endl; } if (t.joinable()) //check if the thread is joinable t.join();//main thread waits till child thread completes the task cout << "main thread exiting" << endl; }