Java TimeUnit Usage getLongFromQueue(BlockingQueue queue)

Here you can find the source of getLongFromQueue(BlockingQueue queue)

Description

get Long From Queue

License

Open Source License

Declaration

public static Long getLongFromQueue(BlockingQueue<Long> queue) 

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_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);
    }
}

Related

  1. getFormattedTimeForMS(Long timeInMillis)
  2. getFriendlyTime(long duration)
  3. getInsertionEndIndex(List list, Delayed key)
  4. getInStringSeconds(String pollInterval)
  5. getLastSlotDate(final int occurrences, final int periodicity, final long firstSlotDate, final int firstSlotDay, final String selectedDays)
  6. getMailServerProps(String toAddress, int smtpPort, int imapPort)
  7. getMinutes(final long milliseconds)
  8. getMinutesBetweenDates(Date begin_date, Date end_date)
  9. getMinutesBetweenDates(Date firstDate, Date secondDate)