PriorityBlockingQueue

package com.company.bingfa;

import java.util.concurrent.PriorityBlockingQueue;

public class MyPriorityBlockingQueue {
    public static void main(String[] args) {
        PriorityBlockingQueue list = new PriorityBlockingQueue<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("b");

        System.out.println(list.poll());
        System.out.println(list.poll());
        System.out.println(list.poll());
        System.out.println(list.poll());

        /*
            a
            b
            b
            c
         */
    }
}

 

你可能感兴趣的:(Java)