Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Apart from the existing answers , below are few more points that comes to my mind:
1. Look for nested synchronization.
2. Look for the code which is try to acquire another lock while holding one lock .
3.Thread.holdLock(Object) can help to find out whether current thread is holding lock or not.
4. Reentrant Lock gives the list of thread holding its lock
Thread dumps can help identify the deadlocks..they include locking information such as which locks are held by each thread, in which stack frame they were acquired, and which lock a blocked thread is waiting to acquire..
- Anonymous March 17, 2013To triger a thead dump, you can send the JVM process a SIGQUIT signal, ( kill -3) on unix or Ctrl -Break on windows platforms