Is the last line "notifyAll();" necessary? I think it changes the state of the waiting threads, if so, from what to what? Block to Runnable? or one of them from block to runnable while others from block to wait?

If no such a line, what is happending to other threads? the current thread release the lock by exiting the method anyway.