1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// thread example
#include <iostream>       // std::cout
#include <thread>         // std::thread
 
void foo() {
  // do stuff...
}
 
void bar(int x) {
  // do stuff...
}
 
int main() {
  std::thread first (foo);     // spawn new thread that calls foo()
  std::thread second (bar,0);  // spawn new thread that calls bar(0)
 
  std::cout << "main, foo and bar now execute concurrently...\n";
 
  // synchronize threads:
  first.join();                // pauses until first finishes
  second.join();               // pauses until second finishes
 
  std::cout << "foo and bar completed.\n";
 
  return 0;
}
cs



이런 스레드 예제가 있는데 여기서 join 메소드를 사용하면 첫번째 스레드가 다 돌때까지 기다리는거잖아


그리고 첫번째 스레드가 다 끝나야 2번째 스레드가 돌아가는거같은데 이러면 스레드 쓰는 의미가 없지않음?


내가 이해를 잘못하고있는거임? 좆고수행님들 설명 부탁드림