Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding join()

Suppose a thread A is running. I have another thread, B, who's not. B has been started, is on runnable state.

What happens if I call: B.join()?

Will it suspend the execution of A or will it wait for A's run() method to complete?

like image 206
andandandand Avatar asked Nov 28 '22 20:11

andandandand


1 Answers

join() will make the currently executing thread to wait for the the thread it is called on to die.

So - If A is running, and you call B.join(), A will stop executing until B ends/dies.

like image 170
brabster Avatar answered Dec 04 '22 08:12

brabster