Advertisement
Evilerus

w02_1

Apr 24th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package tk.evilus;
  2.  
  3. public class w02_1 extends Thread {
  4.    
  5.     public void run() {
  6.         System.out.println("ID = "+this.getName());
  7.     }
  8.    
  9.    
  10.     public static void main(String[] args) {
  11.         w02_1[] threads = new w02_1[101];
  12.        
  13.         for (int i=0; i<threads.length; i++) {
  14.             threads[i] = new w02_1();
  15.             threads[i].setName(Integer.toString(i));
  16.         }
  17.        
  18.         for (int i=threads.length-1; i>=0; i--) {
  19.             threads[i].run();
  20.         }
  21.        
  22.         while (true) {
  23.             try {
  24.                 for (int i=threads.length-1; i>=0; i--) {
  25.                     threads[i].join();
  26.                 }
  27.                 break;
  28.             } catch (Exception e) {
  29.                 e.printStackTrace(System.out);
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement