9

我以为这很容易找到,但我失败了。

如果我在我的 Groovy 应用程序中使用 GPars 并且我没有指定池大小,将创建多少个线程?是否有默认池大小而不设置一个?

// How many threads will be created? What is the default pool size?
GParsExecutorsPool.withPool {
    // do stuff...
}
4

2 回答 2

18

它(默认情况下)设置为

private static int defaultPoolSize() {
  return Runtime.getRuntime().availableProcessors() + 1;
}

gpars.poolsize您可以通过将调用的 System 属性设置为有效的 Integer 来更改它(我相信)

于 2012-01-12T17:13:28.893 回答
8

CPU 单元数加一,如PoolUtilssource或系统属性所示

retrieveDefaultPoolSize()GParsPool 类在初始化时将其作为最终静态变量调用一次

于 2012-01-12T17:13:44.917 回答