T - public final class AsyncBatchProcessor<T> extends Object
异步数据批处理 execute:直接抛出异常,在线程外部无法捕获异常,想要捕获该异常,可以实现UncaughtExceptionHandler接口 submit :不会抛出异常,需要调用返回值Future对象的get方法 JCTools disruptor
Thread.setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler)| 限定符和类型 | 类和说明 |
|---|---|
static interface |
AsyncBatchProcessor.BatchProcessor<T> |
| 构造器和说明 |
|---|
AsyncBatchProcessor(AsyncBatchProcessor.BatchProcessor<T> processor) |
AsyncBatchProcessor(AsyncBatchProcessor.BatchProcessor<T> processor,
int periodTimeMillis,
int batchSize,
int maximumPoolSize) |
public AsyncBatchProcessor(AsyncBatchProcessor.BatchProcessor<T> processor)
public AsyncBatchProcessor(AsyncBatchProcessor.BatchProcessor<T> processor, int periodTimeMillis, int batchSize, int maximumPoolSize)
processor - 批处理器periodTimeMillis - 处理周期(毫秒)batchSize - 批量大小maximumPoolSize - 最大线程数public boolean put(T element)
element - the elementpublic boolean put(T[] elements)
elements - the elementspublic boolean put(List<T> elements)
elements - the list of elementspublic boolean stop()
true if stop successpublic void stopAndAwait()
throws InterruptedException
Copyright © 2023. All rights reserved.