aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How to make one thread die before another thread Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "How to make one thread die before another thread" Watch "How to make one thread die before another thread" New topic
Author

How to make one thread die before another thread

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 202
Q1) There are three thread A,B,C. I want thread A to finish its execution after thread B and C completes.How to do it? Each time i am getting different output.

Q2) Is it possiable to make main thread die before thread A,B,C?



Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6590
    
    1

One solution would be to chain this up with join(). B->C->A

Is it possiable to make main thread die before thread A,B,C?


Try to make the other threads sleep for a while after they are started by the main thread. What happens ?


SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

amolpalekar kadolkar wrote:Q1) There are three thread A,B,C. I want thread A to finish its execution after thread B and C completes.How to do it? Each time i am getting different output.


Pass those threads(in your case, thread A) to other thread's methods, and call join the thread A in you convenient way.


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to make one thread die before another thread
 
Similar Threads
Thread Synchronization Q
Please explain this code
Thread doubt
Lock Mechanism Doubt
Threads and synchronisation