org.jactr.core.concurrent
Class SafeExecutorService
java.lang.Object
java.util.concurrent.AbstractExecutorService
org.jactr.core.concurrent.SafeExecutorService
- All Implemented Interfaces:
- java.util.concurrent.Executor, java.util.concurrent.ExecutorService
public class SafeExecutorService
- extends java.util.concurrent.AbstractExecutorService
An executor that can be wrapped around others and will check to be sure that
any execute calls are not made from a thread that is managed by this executor
service. this can prevent a fairly nasty and stupid deadlock occurence.
SafeExecutorService ses = new SafeExecutorService(false);
SafeExecutorThreadFactory setf = new SafeExecutorThreadFactory(ses, Executors.defaultThreadFactory());
ses.setDelegate(Executors.newSingleThreadExecutor(setf));
- Author:
- developer
| Methods inherited from class java.util.concurrent.AbstractExecutorService |
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SafeExecutorService
public SafeExecutorService(boolean permitSelfExecutions)
SafeExecutorService
public SafeExecutorService(java.util.concurrent.ExecutorService delegate,
boolean permitSelfExecutions)
setDelegate
public void setDelegate(java.util.concurrent.ExecutorService service)
getDelegate
public java.util.concurrent.ExecutorService getDelegate()
allowsSelfExecutions
public boolean allowsSelfExecutions()
awaitTermination
public boolean awaitTermination(long arg0,
java.util.concurrent.TimeUnit arg1)
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException- See Also:
ExecutorService.awaitTermination(long,
java.util.concurrent.TimeUnit)
isShutdown
public boolean isShutdown()
- See Also:
ExecutorService.isShutdown()
isTerminated
public boolean isTerminated()
- See Also:
ExecutorService.isTerminated()
shutdown
public void shutdown()
- See Also:
ExecutorService.shutdown()
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
- See Also:
ExecutorService.shutdownNow()
execute
public void execute(java.lang.Runnable arg0)
- See Also:
Executor.execute(java.lang.Runnable)
addManagedThread
public void addManagedThread(java.lang.Thread thread)
removeManagedThread
public void removeManagedThread(java.lang.Thread thread)
isManagedThread
public boolean isManagedThread(java.lang.Thread thread)