Use of Notify () & Wait

0

I'm doing an ination between 2 threads, but I need to use the Notify and Wait but I've never used them, the problem I have is that after putting in wait mode the thread and then send a notify the thread is still in a state of wait and I do not know why it is.

public synchronized void llegadataq() {
    System.out.println("Estoy caminando hacia la taquilla ...");
    try {
        Thread.sleep(2000);
        Taquilla.clientefila=true;
        System.out.println("He llegado a la taquilla ...");
        hilos.cliente1.wait();
    }catch(Exception e) {

    }
}

public void atendercliente() {
    while(clientefila!=false) {
        try {
            System.out.println("Ha llegado un cliente");
            Thread.sleep(1000);
            System.out.println("Buenas tardes bienvenido al cinema");
            Thread.sleep(500);
            System.out.println("¿Que pelicula y que funcion desea?");
            System.out.println(""+hilos.cliente1.getState());
            Cliente.pregfun=true;
            if(Cliente.pregfun==true) {
                hilos.cliente1.notify();
            }
            System.out.println("estado 2: "+hilos.cliente1.getState());
        }catch(Exception e) {

        }
    }
}
    
asked by Luis Daniel 19.05.2018 в 21:19
source

0 answers