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

io.castled.utils.ThreadUtils Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package io.castled.utils;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;

@Slf4j
public class ThreadUtils {

    public static void interruptIgnoredSleep(long millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            //no-op
        }

    }

    public static void terminateGracefully(ExecutorService executorService, long waitTimeoutSecs) {
        try {
            executorService.shutdown();
            executorService.awaitTermination(waitTimeoutSecs, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            executorService.shutdownNow();
            //no-op
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy