阻塞队列和定时器

阻塞队列,用于生产者消费者模式

	static BlockingQueue<String> queue = new ArrayBlockingQueue<>(10);//循环式队列
    static BlockingQueue<String> queue2 = new LinkedBlockingDeque<>();//基本上是无上限的
    static BlockingQueue<String> queue3 = new PriorityBlockingQueue<>();//优先级阻塞队列

消费者计算斐波那契数,生产者输入数字

package package1218;

import java.util.Scanner;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;


public class BlockingQueueDemo {
   
    static BlockingQueue<Integer> queue = new ArrayBlockingQueue<>(10);//循环式队列

    private static long fib(int n){
   
        if (n < 2){
   
            return n;
        }
        return fib(n - 1) + fib(n - 2);
    }
    private static class

你可能感兴趣的:(JavaWeb)