Facebook
From Eratic Iguana, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 273
  1.         public void run() {
  2.                 while(true) {
  3.                         try {pojemnosc.acquire(3);
  4.                                 zaladunek.acquire(3);
  5.                                 cegielki.acquire();
  6.                                 Thread.sleep(losuj.nextInt(1700) + 200);
  7.  
  8.                         dostep.lock();
  9.                         System.out.println("P3 dorzucilo cegielke!");
  10.                         System.out.println("SEMAFOR:"+pojemnosc.toString());
  11.                         zamek.lock();
  12.                         tasma.dolozCegielke(3);
  13.                         zamek.unlock();
  14.                        
  15.                         dostep.unlock();
  16.                        
  17.                 }catch (InterruptedException e) {
  18.                         e.printStackTrace();
  19.                 }finally {
  20.                         pojemnosc.release(3);
  21.                 }
  22.         }