IT-Academy

Vlakna join

Oct 31st, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. class TestJoinMethod1 extends Thread{  
  2.  public void run(){  
  3.   for(int i=1;i<=5;i++){  
  4.    try{  
  5.     Thread.sleep(500);  
  6.    }catch(Exception e){System.out.println(e);}  
  7.   System.out.println(i);  
  8.   }  
  9.  }  
  10. public static void main(String args[]){  
  11.  TestJoinMethod1 t1=new TestJoinMethod1();  
  12.  TestJoinMethod1 t2=new TestJoinMethod1();  
  13.  TestJoinMethod1 t3=new TestJoinMethod1();  
  14.  t1.start();  
  15.  try{  
  16.   t1.join();  
  17.  }catch(Exception e){System.out.println(e);}  
  18.   
  19.  t2.start();  
  20.  t3.start();  
  21.  }  
  22. }  
Advertisement
Add Comment
Please, Sign In to add comment