Code example for ArrayBlockingQueue

Methods: poll

0
		} 
	} 
 
	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()); 
			this.handle(session, session.commit(bb.array()));
			//System.out.println("end commit@" + System.currentTimeMillis()); 
			BaseResponsePacket result = queue.poll(timeout, unit);
			//System.out.println("get response@" + System.currentTimeMillis()); 
			if (result == null) {
				//session.close(); 
				//System.out.println("get null response"); 
				throw new TimeOutException("timeout: " + timeout + ", server: " + toString());
Connect your IDE to all the code out there  Get Codota for Java