public class QueueConsumer extends Object implements java.util.function.Consumer<ITask>, AutoCloseable
QueueConsumer consumer = QueueConsumer.of("QueueConsumer");
consumer.accept(()->System.out.println("test1");
| 限定符和类型 | 方法和说明 |
|---|---|
void |
accept(ITask task) |
long |
acceptTaskCount() |
void |
close() |
Collection<ITask> |
getQueue()
提供原始队列,方便可以直接使用更多的方法。
|
static QueueConsumer |
of(String threadName) |
static QueueConsumer |
of(String threadName,
BlockingQueue<ITask> queue)
已过时。
|
static QueueConsumer |
of(String threadName,
int queueCapacity) |
static QueueConsumer |
of(String threadName,
int queueCapacity,
int threadCount) |
int |
size() |
String |
toString() |
<D> java.util.function.Consumer<D> |
toView(ExceptionConsumer<D> dataHandler)
如果不习惯于lambda,那么可以用本方法转换成同类型队列的视图形式使用。
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitandThenpublic static QueueConsumer of(String threadName)
@Deprecated public static QueueConsumer of(String threadName, BlockingQueue<ITask> queue)
public static QueueConsumer of(String threadName, int queueCapacity)
public static QueueConsumer of(String threadName, int queueCapacity, int threadCount)
public void accept(ITask task)
accept 在接口中 java.util.function.Consumer<ITask>public long acceptTaskCount()
public int size()
public <D> java.util.function.Consumer<D> toView(ExceptionConsumer<D> dataHandler)
Consumer<String> consumer = QueueConsumer.of("QueueConsumer").toView(data -> System.out.println(data));
consumer.accept("test1");
D - DdataHandler - handlerpublic Collection<ITask> getQueue()
public void close()
close 在接口中 AutoCloseableCopyright © 2022. All rights reserved.