There is a service that must be run periodically. How best to implement a periodic assignment in Java? What are the pros and cons of using Thread.sleep, TimerTask and a trappool?
package main; import services.Service; public class Main { public static void main(String[] args) { Service s = new Service(); while (true) { s.service(); try { Thread.sleep(5000); } catch (InterruptedException e) { } } } }