Monday, August 5, 2013

programmatically check thread lock in Multi Threaded Environment.

This Code below can check for thread locks in a concurrent environment. this code needs to be executed by a Deamon or Timer task.

                ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
long[] ids = tmx.findDeadlockedThreads();
if (ids != null)
ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true);
LOG.fatal("********************************************The following threads                          are deadlocked:**************************************");
for (ThreadInfo ti : infos)

LOG.fatal("************************************************************                        ************************************************************");

No comments:

Post a Comment