Skip to content

Commit e80b020

Browse files
Merge pull request #141 from sunnyshahabuddin0/patch-3
Create multithreading.cpp
2 parents 22cc983 + 881ffa8 commit e80b020

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

multithreading.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
#include <thread>
3+
4+
void foo() {
5+
for (int i = 0; i < 5; ++i) {
6+
std::cout << "Thread 1: " << i << std::endl;
7+
}
8+
}
9+
10+
int main() {
11+
std::thread t1(foo);
12+
for (int i = 0; i < 5; ++i) {
13+
std::cout << "Main Thread: " << i << std::endl;
14+
}
15+
t1.join();
16+
return 0;
17+
}

0 commit comments

Comments
 (0)