Here you can find the source of putLongToQueue(BlockingQueue
public static void putLongToQueue(BlockingQueue<Long> queue, Long valueToPut)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.BlockingQueue; public class Main { public final static long Q_OFFER_SLEEP_DURATION_ = 50L; public static void putLongToQueue(BlockingQueue<Long> queue, Long valueToPut) { boolean done = false; while (done == false) { boolean offerResult = false; try { offerResult = queue.offer(valueToPut); while (offerResult == false) { Thread.sleep(Q_OFFER_SLEEP_DURATION_); offerResult = queue.offer(valueToPut); }//from www .j ava 2 s . c om done = true; } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }