You have created a deadlock. When you call b.start(), you essentially tell b to hold a lock on a, and then wait for the main
thread to finish before it releases the lock on a. Meanwhile, the main thread sleeps for a second, and after that it asks a to do something. However, it requires a's lock, which is held by b. So it has to wait until b is done with a, while b is waiting for the main thread to finish. Deadlock.