jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mains says :Hey thread jon me !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "mains says :Hey thread jon me !!!" Watch "mains says :Hey thread jon me !!!" New topic

mains says :Hey thread jon me !!!

Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Well, i read that , if we write t1.join() in a main method() where t1 is an instance of thread, then it implies

1. main thread would be moved from Running state to Blocked state with guarantee and would wait for an event of completion of t1 thread.

Problem :- Suppose , i want to say in some thread that join main, then how to do so ???

Thanks !!!

SCJP 6.0 96%

(Connecting the Dots ....)
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

In that case that other thread will need the main thread's instance to call join on. Something like this

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Thanks Ankit....
Great explanation !!!
It is sorta covered in the JavaRanch Style Guide.
subject: mains says :Hey thread jon me !!!
Similar Threads
join() method in Thread doesn't work as expected
Please explain this code
Join() method in Java