题目:请评估一下程序的执行结果?

public class SynchronousQueueQuiz {
    public static void main(String[] args) throws Exception {
        BlockingQueue<Integer> queue = new
        SynchronousQueue<>();
        System. out .print(queue.offer(1) + " ");
        System. out .print(queue.offer(2) + " ");
        System. out .print(queue.offer(3) + " ");
        System. out .print(queue.take() + " ");
        System. out .println(queue.size());
    }
}

1
2
3
4
5
6
7
8
9
10
11
12

A. true true true 1 3

B. true true true (阻塞)

C. false false false null 0

D. false false false (阻塞)

出题人:阿里巴巴出题专家:桃谷/阿里云中间件技术专家

参考答案:D

上次更新: 2019-8-13 16:08:53