【问题标题】:Concurrency and Thread Pools并发和线程池
【发布时间】:2015-02-12 10:01:21
【问题描述】:

如果你想拥有一个只有 10 个线程的线程池,下面哪种技术最能达到这个目的?

  1. 通过传递 10 作为参数来调用 java.util.concurrent.Executors 类的 newCachedThreadPool() 方法。
  2. 通过传递 10 作为参数来调用 java.util.concurrent.Executor 类的 newCachedThreadPool() 方法。
  3. 通过传递 10 作为参数来调用 java.util.concurrent.Executors 类的 newFixedThreadPool() 方法。
  4. 通过传递 10 作为参数来调用 java.util.concurrent.Executor 类的 newFixedThreadPool() 方法。
  5. FixedThreadPool fx = new FixedThreadPool(10);

【问题讨论】:

    标签: concurrency threadpool threadpoolexecutor


    【解决方案1】:

    在您列出的 5 件事中,实际上只有第三件事 exists。所以我建议使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-18
      • 1970-01-01
      • 2019-05-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-29
      • 2012-11-12
      • 2011-11-09
      相关资源
      最近更新 更多