## Why is this an issue?

`ThreadPoolExecutor` is an object that efficiently manages and controls the execution of multiple tasks in a thread pool. A thread pool is a collection of pre-initialized threads ready to execute tasks. Instead of creating a new thread for each task, which can be costly in terms of system resources, a thread pool reuses existing threads.

`java.util.concurrent.ScheduledThreadPoolExecutor` is an extension of `ThreadPoolExecutor` that can additionally schedule commands to run after a given delay or to execute periodically.

`ScheduledThreadPoolExecutor` 's pool is sized with `corePoolSize`, so setting `corePoolSize` to zero means the executor will have no threads and run nothing. `corePoolSize` should have a value greater than zero and valid for your tasks.

This rule detects instances where `corePoolSize` is set to zero via its setter or the object constructor.

### Noncompliant code example

    public void do(){

      int poolSize = 5; // value greater than 0

      ScheduledThreadPoolExecutor threadPool1 = new ScheduledThreadPoolExecutor(0); // Noncompliant

      ScheduledThreadPoolExecutor threadPool2 = new ScheduledThreadPoolExecutor(poolSize);
      threadPool2.setCorePoolSize(0);  // Noncompliant
    }

## Resources

### Documentation

- Oracle Java SE - ScheduledThreadPoolExecutor

### Articles & blog posts

- Zalando - How to set an ideal thread pool size
- Baeldung - ThreadPoolTaskExecutor corePoolSize vs. maxPoolSize