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());
		} 
	} 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE