blockingqueue 的操作

ArrayBlockingQueue<E> queue = new ArrayBlockingQueue<E>(maxStoreSize);
取出
queue.take();

间隔取出 - 用于批处理
queue.poll(timeout, unit);

for (int i = 0; i < bulkSize - 1; i++) {
			try {
				b = q.poll(pollInterval, TimeUnit.MILLISECONDS);
				logger.info("Bulk process task get a filebean from the queue.");
				if (b != null) {
					result.add(b);
				} else {
					logger.debug("BulkProcessTask can't get FB within "
							+ pollInterval);
					break;
				}
			} catch (Exception e) {
				logger.error(e);
				break;
			}
		}

你可能感兴趣的:(BlockingQueue)