Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.lang.management.ManagementFactory;

import java.lang.management.ThreadMXBean;

public class Main {
    public static String getDeadlockedThreads() {
        ThreadMXBean bean = ManagementFactory.getThreadMXBean();
        long[] deadlocked = bean.findMonitorDeadlockedThreads();
        if (deadlocked == null || deadlocked.length == 0) {
            return "";
        }

        String buf = "Deadlocked thread IDs: ";
        for (long id : deadlocked) {
            buf += id + " ";
        }

        return buf;
    }
}