DeadlockExample -- deliberately trying to create a deadlock (and succeeding eventually).
To see this example in action:
  1. Compile the Java source file, DeadlockExample.java:
    	javac DeadlockExample.java
    
  2. Run the class:
    	java DeadlockExample
    
  3. When the threads no longer seem to be making progress, trigger a thread-and-monitor dump (by pressing ctrl-break in Win32, ctrl-\ in Solaris) and check for the characteristic deadlock pattern.

The source.