Code example for BlockingQueue

Methods: put

0
 
	public void addToResults(Integer requestId, BaseResponsePacket response) {
		try { 
			BlockingQueue<BaseResponsePacket> queue = results.get(requestId);
			if (queue != null) 
				queue.put(response);
		} catch (Exception e) {
			throw new RuntimeException("addToResults fail", e);
		} 
	} 
 
	public <T extends BaseResponsePacket> T commit(BasePacket packet) {
		try { 
			BlockingQueue<BaseResponsePacket> queue = new ArrayBlockingQueue<BaseResponsePacket>(1);
			results.put(packet.getRequest(), queue);
			Session session = sessionFactory.getSession(this, address, timeout,
					unit);
			packet.setTimeout(timeout); // set timeout, should before getBuffer
			ByteBuffer bb = packet.getBuffer();
			//System.out.println("start commit@" + System.currentTimeMillis());