Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package edu.uz.instrukcja01.zad02;
  2.  
  3. public class LicznikWatkow {
  4. private int wartoscKrytyczna;
  5.  
  6. public int policzMnie () {
  7. wartoscKrytyczna += 1;
  8. wartoscKrytyczna--;
  9. return wartoscKrytyczna;
  10. }
  11. }
  12.  
  13.  
  14.  
  15. public class WatekLiczacy {
  16. public static void main(String[] args) {
  17.  
  18. int tnum = Integer.parseInt(args[0]);
  19. int count = Integer.parseInt(args[1]);
  20.  
  21. LicznikWatkow licznik = new LicznikWatkow();
  22.  
  23. WatekLiczacy[] thread = new WatekLiczacy[tnum];
  24. for (int i = 0; i<tnum; i++)
  25. thread[i] = new WatekLiczacy("Watek" + (i+1), licznik. count);
  26.  
  27. try{
  28. for (int i=0; i< tnum; i++) {thread[i].join();}
  29. } catch (InterruptedException exc) { System.exit(1); }
  30. System.out.println("Koniec programu");
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement