public class MpscSingleThreadExecutor extends Object implements SingleThreadExecutor
| 构造器和说明 |
|---|
MpscSingleThreadExecutor(int maxPendingTasks,
ThreadFactory threadFactory) |
MpscSingleThreadExecutor(int maxPendingTasks,
ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addShutdownHook(Runnable task)
Add a
Runnable which will be executed on shutdown of this instance. |
protected void |
addTask(Runnable task)
Add a task to the task queue, or throws a
RejectedExecutionException if
this instance was shutdown before. |
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable task) |
boolean |
inWorkerThread(Thread thread) |
boolean |
isShutdown() |
boolean |
isTerminated() |
protected Queue<Runnable> |
newTaskQueue(int maxPendingTasks) |
protected boolean |
offerTask(Runnable task) |
protected static void |
reject() |
protected void |
reject(Runnable task)
Offers the task to the associated
RejectedExecutionHandler. |
void |
removeShutdownHook(Runnable task)
Remove a previous added
Runnable as a shutdown hook. |
boolean |
shutdownGracefully()
Shortcut method for
SingleThreadExecutor.shutdownGracefully(long, TimeUnit) with
sensible default values. |
boolean |
shutdownGracefully(long timeout,
TimeUnit unit)
Signals this executor that the caller wants it to be shutdown.
|
public MpscSingleThreadExecutor(int maxPendingTasks,
ThreadFactory threadFactory)
public MpscSingleThreadExecutor(int maxPendingTasks,
ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler)
public boolean shutdownGracefully()
SingleThreadExecutorSingleThreadExecutor.shutdownGracefully(long, TimeUnit) with
sensible default values.shutdownGracefully 在接口中 SingleThreadExecutorpublic boolean shutdownGracefully(long timeout,
TimeUnit unit)
SingleThreadExecutorshutdownGracefully 在接口中 SingleThreadExecutortimeout - the maximum amount of time to wait until the executor
is shutdownunit - the unit of timeoutpublic void addShutdownHook(Runnable task)
Runnable which will be executed on shutdown of this instance.public void removeShutdownHook(Runnable task)
Runnable as a shutdown hook.public boolean isShutdown()
public boolean isTerminated()
public boolean inWorkerThread(Thread thread)
public boolean awaitTermination(long timeout,
TimeUnit unit)
protected void addTask(Runnable task)
RejectedExecutionException if
this instance was shutdown before.protected final boolean offerTask(Runnable task)
protected final void reject(Runnable task)
RejectedExecutionHandler.task - to reject.protected static void reject()
Copyright © 2021. All rights reserved.