Rather than using Java’s static Thread.sleep method and calculating how many seconds you need to pass to its parameter, a simple class called TimeUnit simplifies its usage according to hours, minutes and seconds. You can use it using either of the following …
|
1 2 3 |
TimeUnit.HOURS.sleep(1); TimeUnit.MINUTES.sleep(10); TimeUnit.SECONDS.sleep(30); |
The sample above will run every hour, every 10 minutes and every 30 seconds. Pretty simple and much less tedious right?
Thread.sleep I have read has no guarantees..Does this have? Don’t think so
Some genuinely nice and utilitarian information on this site, as well I think the style has great features. Thanks!