Java BlockingQueue putLongToQueue(BlockingQueue queue, Long valueToPut)

Here you can find the source of putLongToQueue(BlockingQueue queue, Long valueToPut)

Description

put Long To Queue

License

Open Source License

Declaration

public static void putLongToQueue(BlockingQueue<Long> queue, Long valueToPut) 

Method Source Code


//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();
            }
        }

    }
}

Related

  1. putResponseObject(BlockingQueue queue, Object object)

    HOME | Copyright © www.java2s.com 2016