请评估一下程序的执行结果? 收藏 阅读:21
2020-10-27 11:20:06

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

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());
  }
}

A. true true true 1 3

B. true true true (阻塞)

C. false false false null 0

D. false false false (阻塞)

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

参考答案:D


读后有收获,请作者喝杯咖啡


全部评论

发表评论