org.kuali.common.threads
Class ThreadHandler<T>
java.lang.Object
org.kuali.common.threads.ThreadHandler<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
- Thread.UncaughtExceptionHandler
public class ThreadHandler<T>
- extends Object
- implements Thread.UncaughtExceptionHandler
Handles the execution of threads. The executeThreads() will start all threads and then block until they have
completed. If an exception occurs in a client thread the uncaughtException() method of this ThreadHandler will be
invoked. The default behavior if that happens is to set the stopThreads flag to true and retain a handle to the
exception. Client threads should examine the isStopThreads() method of their handler and shutdown as quickly as
possible if that method returns true.
The default behavior if an exception occurs in a client thread is for the handler to re-throw it once client threads
have completed. If that is not desired, set the rethrowException flag to false. The getException() method can still
be used to obtain the exception thrown in the client thread.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ThreadHandler
public ThreadHandler()
getGroup
public ThreadGroup getGroup()
setGroup
public void setGroup(ThreadGroup group)
getThreads
public Thread[] getThreads()
setThreads
public void setThreads(Thread[] threads)
executeThreads
public void executeThreads()
isThrowException
protected boolean isThrowException()
start
protected void start()
join
protected void join()
uncaughtException
public void uncaughtException(Thread t,
Throwable e)
- Specified by:
uncaughtException
in interface Thread.UncaughtExceptionHandler
isStopThreads
public boolean isStopThreads()
getException
public ThreadHandlerException getException()
getThreadCount
public int getThreadCount()
setThreadCount
public void setThreadCount(int threadCount)
getNotifier
public ProgressNotifier<T> getNotifier()
setNotifier
public void setNotifier(ProgressNotifier<T> notifier)
isRethrowException
public boolean isRethrowException()
setRethrowException
public void setRethrowException(boolean rethrowException)
getExecutionStatistics
public ExecutionStatistics getExecutionStatistics()
Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.