Long time ago, I saved a sentence from a Java reference book: \"Java has no mechanism to handle deadlock. it won\'t even know deadlock occurred.\" (Head First Java 2nd E
If you are on Java 5 you can call the method findMonitorDeadlockedThreads() on the ThreadMXBean which you can get through a call of java.lang.management.ManagementFactory.getThreadMXBean(). This will find deadlocks caused by object monitors only. On Java 6 there's findDeadlockedThreads() which will also find deadlocks caused by "ownable synchronizers (for example ReentrandLock and ReentrantReadWriteLock).
Be aware that it will probably be expensive to call these methods, so they should be used for troubleshooting purposes only.