import
java.lang.management.ManagementFactory;
import
java.lang.management.ThreadInfo;
public
class
GFG {
public
static
void
main(String[] args)
{
try
{
long
id =
10
;
ThreadInfo info
= ManagementFactory.getThreadMXBean()
.getThreadInfo(id);
System.out.println(
"Thread ID: "
+ info.getThreadId());
System.out.println(
"Thread Name: "
+ info.getThreadName());
System.out.println(
"Thread State: "
+ info.getThreadState());
System.out.println(
"Waited count: "
+ info.getWaitedCount());
System.out.println(
"Waited time: "
+ info.getWaitedTime());
System.out.println(
"Times blocked: "
+ info.getBlockedCount());
System.out.println(
"Blocked duration: "
+ info.getBlockedTime());
System.out.println(
"Locked Monitors: "
+ info.getLockedMonitors());
System.out.println(
"Locked Owner's ID: "
+ info.getLockOwnerId());
System.out.println(
"Locked Owner's Name: "
+ info.getLockOwnerName());
}
catch
(Exception e) {
e.printStackTrace();
}
}
}