Code example for BlockingQueue

Methods: add

0
		socket.getInputStream().read(data);
		return new Packet(packetId, data);
	} 
 
	public void queuePacket(Packet packet) {
		writePacketQueue.add(packet);
	} 
 
	public void processPackets() throws IOException { 
		while (!writePacketQueue.isEmpty()) {
			write(writePacketQueue.poll());
		} 
	} 
 
}