public class ThreadlessExecutor extends AbstractExecutorService
Tasks submitted to this executor through execute(Runnable) will not get scheduled to a specific thread, though normal executors always do the schedule.
Those tasks are stored in a blocking queue and will only be executed when a thread calls waitAndDrain(), the thread executing the task
is exactly the same as the one calling waitAndDrain.
| Constructor and Description |
|---|
ThreadlessExecutor(ExecutorService sharedExecutor) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable runnable)
If the calling thread is still waiting for a callback task, add the task into the blocking queue to wait for schedule.
|
CompletableFuture<?> |
getWaitingFuture() |
boolean |
isShutdown() |
boolean |
isTerminated() |
boolean |
isWaiting() |
void |
notifyReturn(Throwable t)
tells the thread blocking on
waitAndDrain() to return, despite of the current status, to avoid endless waiting. |
void |
setWaitingFuture(CompletableFuture<?> waitingFuture) |
void |
shutdown()
The following methods are still not supported
|
List<Runnable> |
shutdownNow() |
void |
waitAndDrain()
Waits until there is a task, executes the task and all queued tasks (if there're any).
|
long |
waitAndDrain(long timeout,
TimeUnit unit) |
public ThreadlessExecutor(ExecutorService sharedExecutor)
public CompletableFuture<?> getWaitingFuture()
public void setWaitingFuture(CompletableFuture<?> waitingFuture)
public boolean isWaiting()
public void waitAndDrain()
throws InterruptedException
InterruptedExceptionpublic long waitAndDrain(long timeout,
TimeUnit unit)
throws InterruptedException,
TimeoutException
InterruptedExceptionTimeoutExceptionpublic void execute(Runnable runnable)
runnable - public void notifyReturn(Throwable t)
waitAndDrain() to return, despite of the current status, to avoid endless waiting.public void shutdown()
public boolean isShutdown()
public boolean isTerminated()
public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
InterruptedExceptionCopyright © 2011–2022 The Apache Software Foundation. All rights reserved.