Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Koll {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- System.out.print("Podaj ilisc watków: ");
- int N = in.nextInt();
- in.close();
- Thread[] watki = new Thread[N];
- for(int i = 0; i<watki.length; i++) {
- watki[i] = new Watek();
- }
- for(int i = 0; i<watki.length; i++) {
- watki[i].start();
- }
- for(int i = 0; i<watki.length; i++) {
- try {
- watki[i].join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- System.out.println("ALL THREADS FINISHED");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement