d1i2p3a4k5

17.IsAliveJoin

Oct 18th, 2014
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. class A extends Thread
  2. {
  3.     public void run()
  4.     {
  5.         int i;
  6.         for(i=0;i<10;i=i+2)
  7.         {
  8.             System.out.println(i);
  9.         }
  10.     }
  11. }
  12. class B extends Thread
  13. {
  14.     public void run()
  15.     {
  16.         int i;
  17.         for(i=1;i<10;i=i+2)
  18.         {
  19.             System.out.println(i);
  20.         }
  21.     }
  22. }
  23. class isalive
  24. {
  25.     public static void main(String args[]) throws InterruptedException
  26.     {  
  27.         A a = new A();
  28.         B b = new B();
  29.         a.start();
  30.         System.out.println("Thread  A is alive :"+a.isAlive());
  31.         b.start();
  32.         System.out.println("Thread  B is alive :"+b.isAlive());
  33.         a.join();
  34.         b.join();
  35.         System.out.println("Thread  A is alive :"+a.isAlive());
  36.         System.out.println("Thread  B  is alive :"+b.isAlive());
  37.     }
  38. }
Add Comment
Please, Sign In to add comment