Problem notifing objects.

One object do that:

boolean ack_recibido = peticion.enviarRequest(request,this);

if (ack_recibido==true)

{

try{

wait(timeout);

System.out.println("timeout passed");

return reply;

}catch (InterruptedException e){

e.printStackTrace();

}

}

returnnull;

and another do that:

publicvoid devolverRespuesta(byte[] reply){

System.out.println("estamos en la clase peticiones");

System.out.println(new String(reply));

arrayComandosRecibidos[contadorComandos-1].setReply(reply);

arrayComandosRecibidos[contadorComandos-1].notifyAll();

}

arrayComandosRecibidos[contadorComandos-1] is the objectt which is waiting, and setreply works, but it not wake up until timeour.

縃ow can I wake up the onject if notify does not work?

Thanks for the answer.

[1564 byte] By [jorgiria] at [2007-11-27 2:27:18]
# 1

> arrayComandosRecibidos[contadorComandos-1] is the objectt

> which is waiting

Note that it is not the object that is waiting, but the thread.

When calling wait on a given object (this in your case), the current thread waits until another thread calls notify(All) on this object (or until given timeout expires.)

So what threads are implied in your code ?

Are you sure that one thread calls wait, and then another thread calls notifyAll (before timeout expires) ?

TimTheEnchantora at 2007-7-12 2:37:50 > top of Java-index,Java Essentials,Java Programming...