All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.lifecycle.ExecutorServiceManager Maven / Gradle / Ivy

There is a newer version: 0.40.13
Show newest version
package io.dropwizard.lifecycle;

import io.dropwizard.util.Duration;

import java.util.concurrent.ExecutorService;

public class ExecutorServiceManager implements Managed {
    private final ExecutorService executor;
    private final Duration shutdownPeriod;
    private final String poolName;

    public ExecutorServiceManager(ExecutorService executor, Duration shutdownPeriod, String poolName) {
        this.executor = executor;
        this.shutdownPeriod = shutdownPeriod;
        this.poolName = poolName;
    }

    @Override
    public void start() throws Exception {
        // OK BOSS
    }

    @Override
    public void stop() throws Exception {
        executor.shutdown();
        executor.awaitTermination(shutdownPeriod.getQuantity(), shutdownPeriod.getUnit());
    }

    @Override
    public String toString() {
        return super.toString() + '(' + poolName + ')';
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy