Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. public static run() {
  2.     try {
  3.         System.out.println("A Thread " + this.name + " foi inicializada.");
  4.  
  5.         System.out.println("A Thread " + this.name + " esta ESPERANDO " + this.demande + " bolinhas.");
  6.  
  7.         sem.acquire(this.demande);
  8.  
  9.         System.out.println("A Thread " + this.name + " PEGOU " + this.demande + " bolinhas.");
  10.         System.out.println("Bolinhas disponiveis: " + sem.availablePermits());
  11.  
  12.         for (j = 0; j < 5; j++) {
  13.             System.out.println(" " + j + " ");
  14.             this.t.sleep(10);
  15.         }
  16.  
  17.         sem.release(this.demande);
  18.  
  19.         System.out.println("A Thread " + this.name + " DEVOLVEU " + this.demande + " bolinhas.");
  20.         System.out.println("Bolinhas disponiveis: " + sem.availablePermits());
  21.  
  22.  
  23.     } catch(InterruptedException ex) {
  24.         System.out.println(ex.getMessage());
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement