Membro desde: 09/02/2008 01:12:58
Mensagens: 189
Offline
A) This code may throw an InterruptedException
B) This code may throw an IllegalStateException
C) This code may throw a TimeoutException after ten minutes
D) This code will not compile unless "obj.wait()" is replaced with "((Thread) obj).wait()"
E) A call to notify() or notifyAll() from another thread may cause this method to complete normally.
A resposta é a A. Porém, pra mim, esse código irá sempre lançar uma "IllegalMonitorStateException", pois o objeto colocado no synchronized não é o mesmo usado para chamar os métodos wait() e notify().
Alguém pode explicar porque a alternativa A é a correta?
Obrigado!
Pérola: "Nunca coloque seu celular em um forno de microondas, pois isso faz com que a bateria exploda" - Manuais de telefones celulares