visad.util
Class ThreadManager
java.lang.Object
visad.util.ThreadManager
public class ThreadManager
- extends Object
This 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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
debug
public boolean debug
MAX_THREADS
public static final int MAX_THREADS
- See Also:
- Constant Field Values
ThreadManager
public ThreadManager()
ThreadManager
public ThreadManager(String theName)
- Constructor with name specified
- Parameters:
theName
-
ThreadManager
public ThreadManager(int maxThreads)
- Parameters:
maxThreads
-
setGlobalMaxThreads
public static void setGlobalMaxThreads(int max)
- Parameters:
max
-
debug
public void debug(String msg)
clearTimes
public static void clearTimes()
addRunnable
public void addRunnable(ThreadManager.MyRunnable runnable)
- Parameters:
runnable
-
handleException
public void handleException(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,
RemoteException
- Parameters:
maxThreads
-
- Throws:
RemoteException
VisADException
runSequentially
public void runSequentially()
throws VisADException,
RemoteException
- Throws:
RemoteException
VisADException
runAllParallel
public void runAllParallel()
throws VisADException,
RemoteException
- Throws:
RemoteException
VisADException
runInParallel
public void runInParallel()
throws VisADException,
RemoteException
- Throws:
RemoteException
VisADException
runInParallel
public void runInParallel(boolean doAverage)
throws VisADException,
RemoteException
- Parameters:
doAverage
-
- Throws:
RemoteException
VisADException
getExceptions
public List<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(String[] args)
throws Exception
- Main method for testing
- Parameters:
args
- args
- Throws:
Exception