Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A extends Thread
- {
- public void run()
- {
- int i;
- for(i=0;i<10;i=i+2)
- {
- System.out.println(i);
- }
- }
- }
- class B extends Thread
- {
- public void run()
- {
- int i;
- for(i=1;i<10;i=i+2)
- {
- System.out.println(i);
- }
- }
- }
- class isalive
- {
- public static void main(String args[]) throws InterruptedException
- {
- A a = new A();
- B b = new B();
- a.start();
- System.out.println("Thread A is alive :"+a.isAlive());
- b.start();
- System.out.println("Thread B is alive :"+b.isAlive());
- a.join();
- b.join();
- System.out.println("Thread A is alive :"+a.isAlive());
- System.out.println("Thread B is alive :"+b.isAlive());
- }
- }
Add Comment
Please, Sign In to add comment