What happens after the wait synchronization?

2

See these two codes on separate threads

Thread A

synchronized(objeto) {
    while(condicao)
        objeto.wait();
    //operações
}

Thread B

synchronized(objeto) {
    condicao = false;
    objeto.notify();
    //operações
}

Will operations be subject to block synchronization?

    
asked by anonymous 06.03.2017 / 14:55

1 answer

1

Yes, since objeto == objeto .

A common problem, especially in complex systems, is that at some point you end up having duplicate instances of objects that should be singleton or, on the contrary, sharing instances that should not be shared.

Another common problem in multi-threading is not properly handling interrupts and timeouts. Failure to handle these things may cause the program to terminate unexpectedly or be permanently blocked, for example.

    
08.03.2017 / 00:09