I want to call a method every 1 minute in Java. Please help me deal with this issue.
thank
Check out TimerTask, which you can plan for re-execution through Timer.scheduleAtFixedRate().
TimerTask
Timer.scheduleAtFixedRate()
Alternatively use a quartz trigger if you need something more complex.
The ScheduledExecutorService is still not visible among the options.
while (true) { try { Thread.sleep(60 * 1000); } catch (InterruptedException ie) { ie.printStackTrace(); } yourMethod(); }
- , , , Timer TimerTask
:
while (...) { Thread.sleep(60000); //do something }