Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threads join() question
#3
(Mar-19-2019, 07:59 PM)nilamo Wrote: Thread.join() will stop the current thread, until the referenced thread has completed. In your example, 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.

thanks nilamo,

that makes sense, but lets suppose t2 somehow finished before t1, t1.join() finishes now the next line will be t2.join() but t2 has already finished running also, what would happen?

thanks
Reply


Messages In This Thread
Threads join() question - by adam2020 - Mar-19-2019, 07:32 PM
RE: Threads join() question - by nilamo - Mar-19-2019, 07:59 PM
RE: Threads join() question - by adam2020 - Mar-19-2019, 08:23 PM
RE: Threads join() question - by nilamo - Mar-19-2019, 08:52 PM
RE: Threads join() question - by adam2020 - Mar-19-2019, 09:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  The difference between os.path.join( and os.sep.join( Pedroski55 2 9,573 Nov-17-2020, 08:38 AM
Last Post: Pedroski55
  Question on Join() function sduvvuri 2 2,798 Jun-02-2019, 03:55 PM
Last Post: perfringo
  SQL select join operation in python(Select.. join) pradeepkumarbe 1 2,270 Feb-14-2019, 08:34 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020