fulmine.util.concurrent
Class ThreadUtils

java.lang.Object
  extended by fulmine.util.concurrent.ThreadUtils

public abstract class ThreadUtils
extends Object

Utilities for working with threads.

Author:
Ramon Servadei

Field Summary
static String DEFAULT_THREAD_DUMP_SAMPLE_RATE
          The default sample rate for thread dumps
static String THREAD_DUMP_SAMPLE_RATE
          System property name for setting the sample rate (in milliseconds) for executing thread dumps.
 
Constructor Summary
ThreadUtils()
           
 
Method Summary
static void dumpThreads()
          Print all thread stack traces to System.out.
static boolean findDeadlocks()
          Find any deadlocked threads.
static void startThreadDumps()
          Kicks off a daemon thread that periodically logs all thread stack traces to the LOG at the Log.info(Object) level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THREAD_DUMP_SAMPLE_RATE

public static final String THREAD_DUMP_SAMPLE_RATE
System property name for setting the sample rate (in milliseconds) for executing thread dumps. Defaults to DEFAULT_THREAD_DUMP_SAMPLE_RATE

See Also:
startThreadDumps(), Constant Field Values

DEFAULT_THREAD_DUMP_SAMPLE_RATE

public static final String DEFAULT_THREAD_DUMP_SAMPLE_RATE
The default sample rate for thread dumps

See Also:
Constant Field Values
Constructor Detail

ThreadUtils

public ThreadUtils()
Method Detail

startThreadDumps

public static void startThreadDumps()
Kicks off a daemon thread that periodically logs all thread stack traces to the LOG at the Log.info(Object) level. This also checks for thread deadlocks during each logging period.

The sample period is defined by the system property THREAD_DUMP_SAMPLE_RATE

This method is idempotent


findDeadlocks

public static boolean findDeadlocks()
Find any deadlocked threads. Deadlocked threads are printed to System.out.

Returns:
true if a deadlock was found

dumpThreads

public static void dumpThreads()
Print all thread stack traces to System.out.



Copyright © 2007-2009. All Rights Reserved.