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

cloud.agileframework.spring.sync.ShutdownManager Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package cloud.agileframework.spring.sync;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;

/**
 * 确保应用退出时能关闭后台线程
 *
 * @author mydeathtrial
 */
@Component
public class ShutdownManager {
    private static final Logger LOGGER = LoggerFactory.getLogger("sys-user");

    @PreDestroy
    public void destroy() {
        shutdownAsyncManager();
    }

    /**
     * 停止异步执行任务
     */
    private void shutdownAsyncManager() {
        try {
            LOGGER.info("====关闭后台任务任务线程池====");
            AsyncManager.shutdown();
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy