E - 队列元素类型public class ExecutableQueue<E extends Serializable> extends Object implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static class |
ExecutableQueue.ExecutableWorker<E> |
static interface |
ExecutableQueue.IFilter<E> |
static interface |
ExecutableQueue.IListener<E> |
| Constructor and Description |
|---|
ExecutableQueue() |
ExecutableQueue(int concurrentCount,
RejectedExecutionHandler rejectedExecutionHandler) |
ExecutableQueue(RejectedExecutionHandler rejectedExecutionHandler) |
ExecutableQueue(String prefix) |
ExecutableQueue(String prefix,
int minPoolSize,
int maxPoolSize,
int workQueueSize,
long queueTimeout,
int queueSize,
int concurrentCount,
RejectedExecutionHandler rejectedExecutionHandler) |
ExecutableQueue(String prefix,
int concurrentCount,
RejectedExecutionHandler rejectedExecutionHandler) |
public ExecutableQueue()
public ExecutableQueue(String prefix)
prefix - 队列名称前缀public ExecutableQueue(RejectedExecutionHandler rejectedExecutionHandler)
rejectedExecutionHandler - 拒绝策略public ExecutableQueue(int concurrentCount,
RejectedExecutionHandler rejectedExecutionHandler)
concurrentCount - 并发数量rejectedExecutionHandler - 拒绝策略public ExecutableQueue(String prefix, int concurrentCount, RejectedExecutionHandler rejectedExecutionHandler)
prefix - 队列名称前缀concurrentCount - 并发数量rejectedExecutionHandler - 拒绝策略public ExecutableQueue(String prefix, int minPoolSize, int maxPoolSize, int workQueueSize, long queueTimeout, int queueSize, int concurrentCount, RejectedExecutionHandler rejectedExecutionHandler)
prefix - 队列名称前缀minPoolSize - 线程池初始大小maxPoolSize - 最大线程数workQueueSize - 工作队列大小queueTimeout - 队列等待超时时间(秒), 默认30秒queueSize - 队列大小concurrentCount - 并发数量rejectedExecutionHandler - 拒绝策略protected void onListenStarted()
protected void onListenStopped()
protected void onListenerAdded(String id, ExecutableQueue.IListener<E> listener)
id - 监听器IDlistener - 监听器对象protected void onListenerRemoved(String id, ExecutableQueue.IListener<E> listener)
id - 监听器IDlistener - 监听器对象(可能为空)protected void onElementAdded(E element)
element - 新元素对象protected void onElementAbandoned(E element)
element - 元素对象public void listenStart()
public void listenStop()
public final void listenStop(long millis)
millis - 等待该线程终止的时间最长为millis毫秒, 为0意味着要一直等下去public void close()
close in interface AutoCloseablepublic boolean checkStatus()
public void addListener(ExecutableQueue.IListener<E> listener)
public void addListener(String id, ExecutableQueue.IListener<E> listener)
id - 监听器IDlistener - 监听器对象public ExecutableQueue.IListener<E> removeListener(Class<? extends ExecutableQueue.IListener<E>> listener)
public ExecutableQueue.IListener<E> removeListener(String id)
id - 监听器IDpublic Map<String,ExecutableQueue.IListener<E>> removeAllListeners()
public void putElement(E element)
public void putElements(Collection<E> elements)
public int getQueueSize()
public int getWorkQueueSize()
public E execute(Callable<E> worker) throws InterruptedException, ExecutionException, TimeoutException
public E execute(Callable<E> worker, long timeout) throws InterruptedException, ExecutionException, TimeoutException
Copyright © 2022. All rights reserved.