Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Koll {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.        
  8.         System.out.print("Podaj ilisc watków: ");
  9.         int N = in.nextInt();
  10.         in.close();
  11.         Thread[] watki = new Thread[N];
  12.        
  13.         for(int i = 0; i<watki.length; i++) {
  14.             watki[i] = new Watek();
  15.         }
  16.        
  17.        
  18.          for(int i = 0; i<watki.length; i++) {
  19.              watki[i].start();
  20.              }
  21.          
  22.          for(int i = 0; i<watki.length; i++) {
  23.              try {
  24.                 watki[i].join();
  25.             } catch (InterruptedException e) {
  26.                 e.printStackTrace();
  27.             }
  28.          }
  29.    
  30.         System.out.println("ALL THREADS FINISHED");
  31.  
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement