Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

join, a Thread question

 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

am i implementing this code right?
my output doesnt take effect of join() usage at all.
"Lucy" would come out before Fred does!
 
Henry Wong
author
Marshal
Pie
Posts: 21212
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am i implementing this code right?
my output doesnt take effect of join() usage at all.
"Lucy" would come out before Fred does!


join() causes the calling thread to wait until the completion of the thread represented by the Thread object. In your example, it will cause the main thread (the thread executing the main method) to wait for the completion of thread two. Thread one runs independently of the other two threads (main and two).

Henry
 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to write code if we want therad two to complete first before thread one ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic