Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static run() {
- try {
- System.out.println("A Thread " + this.name + " foi inicializada.");
- System.out.println("A Thread " + this.name + " esta ESPERANDO " + this.demande + " bolinhas.");
- sem.acquire(this.demande);
- System.out.println("A Thread " + this.name + " PEGOU " + this.demande + " bolinhas.");
- System.out.println("Bolinhas disponiveis: " + sem.availablePermits());
- for (j = 0; j < 5; j++) {
- System.out.println(" " + j + " ");
- this.t.sleep(10);
- }
- sem.release(this.demande);
- System.out.println("A Thread " + this.name + " DEVOLVEU " + this.demande + " bolinhas.");
- System.out.println("Bolinhas disponiveis: " + sem.availablePermits());
- } catch(InterruptedException ex) {
- System.out.println(ex.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement