public class BlockingQueueFactory extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_QUEUE_SIZE |
| 限定符和类型 | 方法和说明 |
|---|---|
static BlockingQueueFactory |
getInstance() |
BlockingQueue<Object> |
getQueue(String key)
根据Key获取阻塞队列
|
static int |
howManyElementInQueues() |
void |
initQueue(String key)
初始化队列
|
void |
initQueue(String key,
int size)
初始化队列
|
boolean |
offer(String key,
Object bean)
向队列中添加元素
|
boolean |
offer(String key,
Object bean,
Long time,
TimeUnit unit)
在设定时间内向队列中添加元素,超时抛出中断异常
|
<T> T |
poll(String key)
从队列中获取元素
|
<T> List<T> |
poll(String key,
int size,
long time,
TimeUnit unit) |
<T> T |
poll(String key,
Long time,
TimeUnit unit)
在设定时间内从队列中获取元素,超时抛出中断异常
|
void |
put(String key,
Object bean)
向队列中添加元素
|
void |
setQueue(String key,
ArrayBlockingQueue<Object> queue)
向工厂中添加队列
|
Object |
take(String key)
从队列中获取元素
|
public static final int DEFAULT_QUEUE_SIZE
public static BlockingQueueFactory getInstance()
public BlockingQueue<Object> getQueue(String key) throws RuntimeException
key - 队列KeyRuntimeException - 运行时异常public void initQueue(String key, int size)
key - 队列Keysize - 队列大小public void initQueue(String key)
key - 队列Keypublic void setQueue(String key, ArrayBlockingQueue<Object> queue)
key - 队列Keyqueue - 队列public void put(String key, Object bean) throws InterruptedException
key - 队列Keybean - 对象InterruptedException - 中断异常public Object take(String key) throws InterruptedException
key - 队列KeyInterruptedException - 中断异常public boolean offer(String key, Object bean, Long time, TimeUnit unit) throws InterruptedException
key - 队列Keybean - 对象time - 超时时间unit - 时间类型InterruptedException - 中断异常public <T> T poll(String key)
T - the value typekey - 队列keypublic <T> T poll(String key, Long time, TimeUnit unit) throws InterruptedException
T - the value typekey - 队列Keytime - 超时时间unit - 时间类型InterruptedException - 中断异常public static final int howManyElementInQueues()
Copyright © 2015–2016. All rights reserved.