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.
| 构造器和说明 |
|---|
ThreadlessExecutor(ExecutorService sharedExecutor) |
| 限定符和类型 | 方法和说明 |
|---|---|
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
public long waitAndDrain(long timeout,
TimeUnit unit)
throws InterruptedException,
TimeoutException
public 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
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.