fork download
  1. class Main {
  2. public static void main(String[] args) {
  3. Thread t1 = new Thread(new DeadlockRunnable());
  4. t1.start();
  5. }
  6. }
  7.  
  8. class DeadlockRunnable implements Runnable {
  9. static Object onlyData = new Object();
  10.  
  11. public void run() {
  12. synchronized(onlyData) {
  13. synchronized(onlyData) {
  14. System.out.println("*** Successfully acquired both the locks");
  15. }
  16. }
  17. }
  18. }
Success #stdin #stdout 0.02s 246016KB
stdin
Standard input is empty
stdout
*** Successfully acquired both the locks