title: Is it possible for a thread to Deadlock itself?
body: <p>Is it technically possible for a thread in Java to deadlock itself?</p>
  
  <p>I was asked this at an interview a while back and responded that it wasn't possible but the interviewer told me that it is. Unfortunately I wasn't able to get his method on how to achieve this deadlock.</p>
  
  <p>This got me thinking and the only situation that I can think of is where you can have this happen is where you have an RMI server process which contained a method that calls itself. The line of code that calls the method is placed in a synchronized block.</p>
  
  <p>Is that even possible or was the interviewer incorrect?</p>
  
  <p>The source code I was thinking about was along these lines (where testDeadlock is running in an RMI server process)</p>
  
  <pre><code>public boolean testDeadlock () throws RemoteException {
      synchronized (this) {
          //Call testDeadlock via RMI loopback            
      }
  }
  </code></pre>