提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.framework.manager; |
懒 |
2 |
|
|
3 |
import org.slf4j.Logger; |
|
4 |
import org.slf4j.LoggerFactory; |
|
5 |
import org.springframework.stereotype.Component; |
|
6 |
import javax.annotation.PreDestroy; |
|
7 |
|
|
8 |
/** |
|
9 |
* 确保应用退出时能关闭后台线程 |
|
10 |
* |
|
11 |
* @author jc |
|
12 |
*/ |
|
13 |
@Component |
|
14 |
public class ShutdownManager |
|
15 |
{ |
|
16 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
|
17 |
|
|
18 |
@PreDestroy |
|
19 |
public void destroy() |
|
20 |
{ |
|
21 |
shutdownAsyncManager(); |
|
22 |
} |
|
23 |
|
|
24 |
/** |
|
25 |
* 停止异步执行任务 |
|
26 |
*/ |
|
27 |
private void shutdownAsyncManager() |
|
28 |
{ |
|
29 |
try |
|
30 |
{ |
|
31 |
logger.info("====关闭后台任务任务线程池===="); |
|
32 |
AsyncManager.me().shutdown(); |
|
33 |
} |
|
34 |
catch (Exception e) |
|
35 |
{ |
|
36 |
logger.error(e.getMessage(), e); |
|
37 |
} |
|
38 |
} |
|
39 |
} |