Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pcd.mod.pkg3;
- /**
- *
- * @author VSPC-Infernov4
- */
- public class Registro {
- private int oficiales = 0;
- private int registrador = 0;
- private int registrador_atiende = 0;
- public synchronized void EntraSimple(int id) throws InterruptedException {
- while (oficiales == 3 && registrador == 1) {
- System.out.println("Cliente para nota simple con id " + id + " está esperando.");
- wait();
- }
- if (oficiales < 3) {
- oficiales++;
- } else if (registrador==0) {
- registrador++;
- registrador_atiende = id;
- }
- System.out.println("Cliente para nota simple con id " + id + " está siendo atendido.");
- System.out.println("Oficiales: " + oficiales + " registrador: " + registrador + "\n");
- }
- public synchronized void SaleSimple(int id) {
- if (oficiales <= 3 && registrador_atiende!=id) {
- oficiales--;
- } else {
- registrador--;
- }
- System.out.println("Cliente para nota simple con id " + id + " se va.");
- notifyAll();
- System.out.println("Oficiales: " + oficiales + " registrador: " + registrador + "\n");
- }
- public synchronized void EntraPropiedad(int id) throws InterruptedException {
- while (registrador == 1) {
- System.out.println("Cliente para reg. propiedad con id " + id + " está esperando.");
- wait();
- }
- oficiales++;
- registrador++;
- System.out.println("Cliente para reg. propiedad con id " + id + " está siendo atendido.");
- System.out.println("Oficiales: " + oficiales + " registrador: " + registrador + "\n");
- }
- public synchronized void SalePropiedad(int id) {
- oficiales--;
- registrador--;
- System.out.println("Cliente para reg. propiedad con id " + id + " se va.");
- notifyAll();
- System.out.println("Oficiales: " + oficiales + " registrador: " + registrador + "\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement