Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread join() method

 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



join() is called on Thread-1(that means, reference a) and called by mainthread.That means mainthread will wait until the thread-1(a) will die.
So thread-1 is completed first holding 1 value.then that(1) value is printed for a.i.

I wanted to make sure that I got the join() method correctly.Am i correct...
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are correct.

Here, a.join() means main thread will wait for a to complete. By this way, a will successfully assign 1 to i before main thread prints it.

Naseem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic