Class SameThreadExecutorService
java.lang.Object
ch.raffael.meldioc.util.concurrent.SameThreadExecutorService
- All Implemented Interfaces:
AutoCloseable,Executor,ExecutorService
Executor that runs all tasks in the submitting thread.
It does, however, honor the contract of executor services. Several
tasks can be run concurrently (when submitted from multiple threads), it
doesn't accept any new work on shutdown, awaitTermination() waits until all tasks are done.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, @NotNull TimeUnit unit) voidinvokeAll(@NotNull Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) invokeAll(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(@NotNull Collection<? extends Callable<T>> tasks) <T> TinvokeAny(@NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull TimeUnit unit) booleanbooleanvoidshutdown()Future<?><T> Future<T><T> Future<T>Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
close
-
Constructor Details
-
SameThreadExecutorService
public SameThreadExecutorService()
-
-
Method Details
-
execute
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
invokeAll
- Specified by:
invokeAllin interfaceExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(@NotNull @NotNull Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) - Specified by:
invokeAllin interfaceExecutorService
-
invokeAny
public <T> T invokeAny(@NotNull @NotNull Collection<? extends Callable<T>> tasks) throws ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
ExecutionException
-
invokeAny
@Nullable public <T> T invokeAny(@NotNull @NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull @NotNull TimeUnit unit) throws ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
ExecutionException
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, @NotNull @NotNull TimeUnit unit) throws InterruptedException - Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-