Create new Priority Blocking Queue - Java java.util

Java examples for java.util:Collection Creation

Description

Create new Priority Blocking Queue

Demo Code


//package com.java2s;

import java.util.Collection;
import java.util.Comparator;

import java.util.concurrent.PriorityBlockingQueue;

public class Main {
    public static void main(String[] argv) {
        System.out.println(newPriorityBlockingQueue());
    }/*from  w  w w  . j  ava  2s .  c  o m*/

    public static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue() {
        return new PriorityBlockingQueue<E>();
    }

    public static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue(
            final Collection<? extends E> c) {
        return new PriorityBlockingQueue<E>(c);
    }

    public static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue(
            final int initialCapacity) {
        return new PriorityBlockingQueue<E>(initialCapacity);
    }

    public static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue(
            final int initialCapacity,
            final Comparator<? super E> comparator) {
        return new PriorityBlockingQueue<E>(initialCapacity, comparator);
    }
}

Related Tutorials