Threading in C++ Example with Code
#include <bits/stdc++.h>
#include<thread>
#include<unistd.h>
using namespace std;
void solve() {
for (int i = 0; i < 10; i++)
{
sleep(1);
cout<<i<<endl;
fflush(stdout);
}
}
void solve2(){
for (int i = 20; i < 30; i++)
{
sleep(1);
cout<<i<<endl;
fflush(stdout);
}
}
int32_t main()
{
thread t1(solve);
thread t2(solve2);
t1.join();
t2.join();
return 0;
}
c++ multithreading
multithreading in c
c++ thread example
c++ create thread
multithreading in cpp
thread cpp
create thread c++
c++ multithreading tutorial
cpp multithreading
0 Comments
If you have any doubts/suggestion/any query or want to improve this article, you can comment down below and let me know. Will reply to you soon.