
Thread Priorities 7.21
3. import com.oops.chap7.SecondThread2;
4. public class IsAliveJoinDemo {
5. public static void main(String[] args) {
6. FirstThread2 obj1= new FirstThread2();
7. SecondThread2 obj2 =new SecondThread2();
8. // check if threads are alive. thrd1&2 is objects of First/
SecondThread2
9. System.out.println(obj1.thrd1.isAlive());//thrd1 is object of
FirstThread2
10. System.out.println(obj2.thrd2.isAlive());
11. // wait for threads to finish. Use join method
12. try{
13. System.out.println(“\nwaiting for threads to finish”);
14. obj1.thrd1.join();
15. obj2.thrd2.join();
16. }catch(InterruptedException e )
17. {System.out.println(“main ...