Advertisement
Guest User

Untitled

a guest
May 30th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package Zadanie2;
  2.  
  3. public class WatekA implements Runnable{
  4.  
  5.     @Override
  6.     public void run() {
  7.         Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
  8.         while(true){
  9.             try {
  10.                 IncA();
  11.             } catch (InterruptedException e) {
  12.                 // TODO Auto-generated catch block
  13.                 e.printStackTrace();
  14.             }
  15.         }  
  16.     }
  17.  
  18.     private synchronized void IncA() throws InterruptedException{
  19.         Rywalizacja.A++;
  20.         Rywalizacja.Counter++;
  21.         System.out.println("Wykonuje sie watek A: " + Rywalizacja.A);
  22.         notify();
  23.         Thread.sleep(1000);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement