jfcmacro

Jardin Limitado implementa interfaz ISync

Mar 28th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. public class Jardin implements ISync {
  2.  
  3.     private int contador;
  4.  
  5.     public Jardin() {
  6.     this.contador = 0;
  7.     }
  8.  
  9.     public synchronized void entrar() {
  10.     contador++;
  11.     }
  12.  
  13.     public synchronized void salir() {
  14.     contador--;
  15.     }
  16.  
  17.     public synchronized int obtContador() {
  18.     return contador;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment