Resilience4J的线程永远停留在“运行”状态中。

huangapple go评论102阅读模式
英文:

Resilience4J threads stuck in Running state forever

问题

我fork了spring-boot2-demo仓库到this

做了以下更改:

BackendBController.java

@GetMapping("futureTimeout")
public String futureTimeout(){
    for(int i=0; i<1000; i++){
        executeAsyncWithFallback(this::timeout, this::fallback);
    }
    return "Something";
}

我在BackedBController中调用了/futureTimeout端点。

我在JVisualVM中看到了这个

Resilience4J的线程永远停留在“运行”状态中。

我正在尝试理解这是否是预期行为,即一旦工作完成,线程是否仍然保持活动状态?它们不应该被关闭吗?

英文:

I forked the spring-boot2-demo repo to this

Did these changes :

BackendBController.java

@GetMapping(&quot;futureTimeout&quot;)
public String futureTimeout(){
    for(int i=0; i&lt; 1000; i++){
        executeAsyncWithFallback(this::timeout, this::fallback);
    }
    return &quot;Something&quot;;
}

I invoked the /futureTimeout endpoint in BackedBController

I see this in JVisualVM

Resilience4J的线程永远停留在“运行”状态中。

I am trying to understand if this the expected behavior i.e. Once the job is complete will threads remain active? Shouldn't they be closed?

答案1

得分: 0

https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html

corePoolSize 表示线程池创建后始终保持活动的线程数量。只有超过 maximumPoolSize-corePoolSize 的额外线程会在任务完成后被创建和销毁。

英文:

From https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html

corePoolSize number of threads will always be active once the threadpool is created. It's only the excess maximumPoolSize-corePoolSize that will be created & destroyed after completion of the tasks.

huangapple
  • 本文由 发表于 2020年10月13日 04:50:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/64325189.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定