Resilience4J threads stuck in Running state forever

197 views Asked by At

I forked the spring-boot2-demo repo to this

Did these changes :

BackendBController.java

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

I invoked the /futureTimeout endpoint in BackedBController

I see this in JVisualVM

enter image description here

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

There are 1 answers

0
Hexy On BEST ANSWER

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.