Skip to content

Commit 881ffa8

Browse files
Create multithreading.cpp
1 parent 0cb3949 commit 881ffa8

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)