BlockingQueue为阻塞队列,它的实现形式有许多中,有固定的,链表的等等。机制都一样,让进入的线程加入等待 以下是BlockingQueue 阻塞队列版多线程消费生产实例: public class Fetcher implements Runnable {private Blo…
1.基于wait和notify方法实现的阻塞队列
public class WaitNotifyInterview {public final static int QUEUE_SIZE 10;public static PriorityQueue<Integer> queue new PriorityQueue<>();public static void main(String[] args) {new Thread(() -> {while …