Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these correctly obtains a fixed pool of four threads?

  • A.ExecutorService es = ExecutorService.create(4);
  • B.ExecutorService es = Executors.newFixedThreadPool(4);
  • C.ExecutorService es = new ExecutorService(4);
  • D.ExecutorService es = new FixedThreadPool(4);

Answer: B

Executors is a factory class of static methods, and newFixedThreadPool is the one that takes a thread count. ExecutorService is an interface and cannot be constructed, and there is no public FixedThreadPool class to instantiate.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.