Mar-19-2019, 07:59 PM
Thread.join() will stop the current thread, until the referenced thread has completed. In your example,
Once
t1.join()
would stop the main thread, while both t1
and t2
continue running. Once t1
completes, the main thread would resume. The very next line, t2.join()
, would again halt the main thread until t2
had completed. At that point, you had already guaranteed that t1
had completed, so the only running thread would be t2
.Once
t2
completes, the main thread would resume. At the next instruction, print("bye")
, the main thread is the only thread still running.