Reputation: 977
int main(){
std::thread t1(findEven, start, end, &(EvenSum));
std::thread t2(findOdd, start, end, &(OddSum));
t1.join();
t2.join();
}
Assume that findEven and findOdd are some functions that has already been written . For better understandig , this is the code Link to Code
Having some difficulty in understanding threading concepts and wanted to check if my understanding is correct? My main thread created a new thread T1 and ran the function Evensum .It did not wait for evensum to finish and came back and again launched a new thread T2 and running findodd at same time .now both t1 and t2 are running at the same time .that's fine. now it hits t1.join () . Does it mean that the line t2.join() is not reached as long as t1 is not finished?
Upvotes: 0
Views: 302
Reputation: 5369
Your understanding is totally correct.
Upvotes: 1