Here you can find the source of getLongFromQueue(BlockingQueue
public static Long getLongFromQueue(BlockingQueue<Long> queue)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.BlockingQueue; public class Main { public final static long Q_POLL_SLEEP_DURATION_ = 50L; public static Long getLongFromQueue(BlockingQueue<Long> queue) { Long nextValue = null;/* w ww .ja va 2 s. co m*/ boolean done = false; while (done == false) { try { nextValue = queue.poll(); while (nextValue == null) { //nextValue=queue.poll(PropertiesHelper.POLL_DURATION_, TimeUnit.MILLISECONDS); Thread.sleep(Q_POLL_SLEEP_DURATION_); nextValue = queue.poll(); } done = true; } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return (nextValue); } }