This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

understanding join method  RSS feed

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose i have a class that extends thread and in it i have a method mySample() as shown below. further i call mySample() from main method.



so when we enter mySample(), we will call join on the main thread and the currently running thread is also main. so what does it mean. does main thread will join with itself ? does that mean after join() call no more code will run since main thread is waiting for itself to die. ?
 
Henry Wong
author
Sheriff
Posts: 22851
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gurpeet singh wrote:suppose i have a class that extends thread and in it i have a method mySample() as shown below. further i call mySample() from main method.



so when we enter mySample(), we will call join on the main thread and the currently running thread is also main. so what does it mean. does main thread will join with itself ? does that mean after join() call no more code will run since main thread is waiting for itself to die. ?



The join() method is a method of the Thread class -- the method will wait for the thread (that is represented by the thread object) to finish. And if I remember correctly, if you never started it, should return immediately.

Henry
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks alot Henry.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!