如何在java中指定的时间延迟后启动线程
2022-09-01 11:21:19
我在ServletContextListener中调用了一个方法作为线程.现在,根据我的需要,我必须将线程延迟1分钟,然后开始执行线程中调用的方法,但我无法做到这一点,因为我在这方面非常新...
这是我的代码...
public class Startup implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
public void contextInitialized(ServletContextEvent sce) {
// Do your startup work here
System.out.println("Started....");
//captureCDRProcess();
new Thread(new Runnable() {
@Override
public void run() {
captureCDRProcess();
}
}).start();
}
请帮帮我..提前致谢..