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(ti);
}

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

Comments

Popular posts from this blog

'jasypt.encryptor.password' or one of ['jasypt.encryptor.privateKeyString', 'jasypt.encryptor.privateKeyLocation'] must be provided for Password-based or Asymmetric encryption

Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - Spring Batch

java.security.spec.InvalidKeySpecException: Only RSAPrivate(Crt)KeySpec and PKCS8EncodedKeySpec supported for RSA private keys