I came across this example on Oracle\'s Java Tutorial describing Deadlock in multi threading scenarios.
So in this example I made following change at line 17 and lin
The deadlock is not dependent on the println function at all. It's caused by the two threads trying to access each other, and locking on each other.
The change from format to println will have introduced sufficient latency in the program to allow the threads to lock each other without colliding, i.e., deadlocking. So you haven't really fixed it; you've just added some latency that means the threads don't deadlock.