I have 2 matrices and I need to multiply them and then print the results of each cell. As soon as one cell is ready I need to print it, but for example I need to print the [
While using the wait
and notify
or notifyAll
methods in Java the following things must be remembered:
notifyAll
instead of notify
if you expect that more than one thread will be waiting for a lock. wait()
method in a loop because if multiple threads are waiting for a lock and one of them got the lock and reset the condition, then the other threads need to check the condition after they wake up to see whether they need to wait again or can start processing. wait()
and notify()
method; every object has its own lock so calling wait()
on object A and notify()
on object B will not make any sense.