Search in sources :

Example 1 with ThreadWarningSystem

use of gate.util.ThreadWarningSystem in project gate-core by GateNLP.

the class Main method main.

/**
 * Main routine for GATE.
 * Command-line arguments:
 * <UL>
 * <LI>
 * <B>-h</B> display a short help message
 * <LI>
 * <B>-d URL</B> define URL to be a location for CREOLE resoures
 * <LI>
 * <B>-i file</B> additional initialisation file (probably called
 *   <TT>gate.xml</TT>). Used for site-wide initialisation by the
 *   start-up scripts
 * </UL>
 */
public static void main(String[] args) throws GateException {
    // check we have a useable JDK
    if (System.getProperty("java.version").compareTo(Gate.getMinJdkVersion()) < 0) {
        throw new GateException("GATE requires JDK " + Gate.getMinJdkVersion() + " or newer");
    }
    ThreadWarningSystem tws = new ThreadWarningSystem();
    tws.addListener(new ThreadWarningSystem.Listener() {

        final PrintStream out = System.out;

        @Override
        public void deadlockDetected(ThreadInfo inf) {
            out.println("Deadlocked Thread:");
            out.println("------------------");
            out.println(inf);
            for (StackTraceElement ste : inf.getStackTrace()) {
                out.println("\t" + ste);
            }
        }

        @Override
        public void thresholdExceeded(ThreadInfo[] threads) {
        }
    });
    // process command-line options
    processArgs(args);
    runGui();
}
Also used : PrintStream(java.io.PrintStream) ThreadInfo(java.lang.management.ThreadInfo) GateException(gate.util.GateException) ThreadWarningSystem(gate.util.ThreadWarningSystem)

Aggregations

GateException (gate.util.GateException)1 ThreadWarningSystem (gate.util.ThreadWarningSystem)1 PrintStream (java.io.PrintStream)1 ThreadInfo (java.lang.management.ThreadInfo)1