Class CommonExecutorService

  • All Implemented Interfaces:
    Executor, ExecutorService, ScheduledExecutorService, ExecutorServiceEx

    public class CommonExecutorService
    extends ScalingThreadPoolExecutor
    implements ScheduledExecutorService
    This is the common executor service each TeamCity service or plugin should use unless it requires a separate ExecutorService for some specific purpose.

    The idea behind is to use a single executor service for both scheduled and non-scheduled tasks.

    Since the standard ScheduledExecutorService implementation - ScheduledThreadPoolExecutor (which can run immediate tasks also) is actually based on a fixed-sized thread pool, it's not very convenient for us because we want the number of threads running to vary depending on the workload.

    That's why this implementation is based on the two JDK executor services - ScheduledThreadPoolExecutor and ThreadPoolExecutor.

    The first one is used only for scheduled tasks while the other one is used for the tasks requiring immediate execution.