visad.util
Class ThreadManager
- java.lang.Object
-
- visad.util.ThreadManager
-
public class ThreadManager extends java.lang.ObjectThis class provides support for running a collection of Runnables concurrently. It will collect and then throw any exceptions that are thrown. It uses the static maxThreads as the number of threads to run. The default is 1, resulting in sequential execution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static interfaceThreadManager.MyRunnableMyRunnable
-
Field Summary
Fields Modifier and Type Field and Description booleandebugstatic intMAX_THREADS
-
Constructor Summary
Constructors Constructor and Description ThreadManager()ThreadManager(int maxThreads)ThreadManager(java.lang.String theName)Constructor with name specified
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddRunnable(ThreadManager.MyRunnable runnable)static voidclearTimes()voiddebug(java.lang.String msg)static voiddoWork(int amt, int[] A)java.util.List<java.lang.Exception>getExceptions()Return the list of any exceptions that were thrown when running the threadsintgetNumRunnables()voidhandleException(java.lang.Exception exc)static voidmain(java.lang.String[] args)Main method for testingvoidrunAllParallel()voidrunInParallel()voidrunInParallel(boolean doAverage)voidrunInParallel(int maxThreads)voidrunnableStarted()voidrunnableStopped()voidrunSequentially()static voidsetGlobalMaxThreads(int max)
-
-
-
Field Detail
-
debug
public boolean debug
-
MAX_THREADS
public static final int MAX_THREADS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ThreadManager
public ThreadManager()
-
ThreadManager
public ThreadManager(java.lang.String theName)
Constructor with name specified- Parameters:
theName-
-
ThreadManager
public ThreadManager(int maxThreads)
- Parameters:
maxThreads-
-
-
Method Detail
-
setGlobalMaxThreads
public static void setGlobalMaxThreads(int max)
- Parameters:
max-
-
debug
public void debug(java.lang.String msg)
-
clearTimes
public static void clearTimes()
-
addRunnable
public void addRunnable(ThreadManager.MyRunnable runnable)
- Parameters:
runnable-
-
handleException
public void handleException(java.lang.Exception exc)
- Parameters:
exc-
-
runnableStopped
public void runnableStopped()
-
runnableStarted
public void runnableStarted()
-
getNumRunnables
public int getNumRunnables()
- Returns:
- count of Runnables
-
runInParallel
public void runInParallel(int maxThreads) throws VisADException, java.rmi.RemoteException- Parameters:
maxThreads-- Throws:
java.rmi.RemoteExceptionVisADException
-
runSequentially
public void runSequentially() throws VisADException, java.rmi.RemoteException- Throws:
java.rmi.RemoteExceptionVisADException
-
runAllParallel
public void runAllParallel() throws VisADException, java.rmi.RemoteException- Throws:
java.rmi.RemoteExceptionVisADException
-
runInParallel
public void runInParallel() throws VisADException, java.rmi.RemoteException- Throws:
java.rmi.RemoteExceptionVisADException
-
runInParallel
public void runInParallel(boolean doAverage) throws VisADException, java.rmi.RemoteException- Parameters:
doAverage-- Throws:
java.rmi.RemoteExceptionVisADException
-
getExceptions
public java.util.List<java.lang.Exception> getExceptions()
Return the list of any exceptions that were thrown when running the threads- Returns:
- The exceptions that were thrown
-
doWork
public static final void doWork(int amt, int[] A)
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionMain method for testing- Parameters:
args- args- Throws:
java.lang.Exception
-
-
DMelt 3.0 © DataMelt by jWork.ORG