Interview Questions

How can you ensure all threads that started from main must end in order in which they started and also main should end in last?

Java Interview Questions and Answers (part 4)


(Continued from previous question...)

8. How can you ensure all threads that started from main must end in order in which they started and also main should end in last?

Interviewers tend to know interviewees knowledge about Thread methods. So this is time to prove your point by answering correctly. We can use join() method to ensure all threads that started from main must end in order in which they started and also main should end in last.In other words waits for this thread to die. Calling join() method internally calls join(0);

DETAILED DESCRIPTION : Join() method - ensure all threads that started from main must end in order in which they started and also main should end in last. Types of join() method with programs- 10 salient features of join.

(Continued on next question...)

Other Interview Questions