[Solved] Java – Thread.join( ) does not release the lock


That’s because Thread.join() doesn’t release any locks. You’ve designed a perfectly working deadlock, where Thread-1 is waiting for Thread-2 to die having locked on Foo, and Thread-2 is waiting to lock on Foo.

(Technically speaking the current implementation does release locks, as it uses internally wait() while synchronized on Thread. However that’s an internal mechanism not related to user code)

solved Java – Thread.join( ) does not release the lock