I have java console application what will run as daemon where I want to use Timer.schedule to execute task every n seconds.
Timer timer = new Timer(true);
timer.schedule(new ATask(), 0,10000);
//insert block here
What is the best way to "block" from exiting?
try Thread#join()
your current Thread.
Timer timer = new Timer(true);
timer.schedule(new ATask(), 0,10000);
Thread currentThread = Thread.currentThread();
currentThread.join();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.