V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  mxinyi1212  ›  全部回复第 1 页 / 共 1 页
回复总数  1
2022-11-15 10:33:45 +08:00
回复了 gzk329 创建的主题 程序员 Springboot 中 想要重启服务 该怎么写?
之前这么用过

public void restart(){
ExecutorService threadPool = new ThreadPoolExecutor(1,1,0, TimeUnit.SECONDS,new ArrayBlockingQueue<>( 1 ),new ThreadPoolExecutor.DiscardOldestPolicy ());
threadPool.execute (()->{
context.close ();
//do xxxx
}
context = SpringApplication.run ( Application.class,args );
} );
threadPool.shutdown ();

}
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2940 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 13:09 · PVG 21:09 · LAX 06:09 · JFK 09:09
Developed with CodeLauncher
♥ Do have faith in what you're doing.