Code example for LinkedBlockingQueue

Methods: take

0
	private void createPacketFromMessageAndSend()  
	{	 
		MessageWithUid m;
		try  
		{ 
			m = blockingRequestsQueue.take();
			RequestMessage request = (RequestMessage) m.getMessage();
			String requestString = generateStringFromRequest(request);
			 
			long uid = m.getUid();
			 
			Log.d(TAG, "out going message: " + requestString + " uid: " + (int)uid);
			 
			byte[] uidBytes = longToBytes(uid);
			byte[] messageBytes = null;
			try { 
				messageBytes = requestString.getBytes("UTF-8");
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block 
				e.printStackTrace();
			}