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

Discussion

Which of these correctly declares a thread pool that reuses idle threads and creates new ones as needed?

  • A.ExecutorService es = Executors.newElasticPool();
  • B.ExecutorService es = new CachedThreadPool();
  • C.ExecutorService es = Executors.newCachedThreadPool();
  • D.ExecutorService es = Executors.newCachedThreadPool(10);

Answer: C

newCachedThreadPool takes no size argument, which is the point: the pool grows on demand and retires idle threads. A bounded pool is what newFixedThreadPool provides, and there is no public CachedThreadPool class or newElasticPool method.

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

Post your comment

Please log in or register to post a comment.