I need to do some periodic checks in Java code. Some things get executed in separate threads, and there I need to check things every 5 seconds, then some other things every 10 minutes, etc.
How should I implement these "timers" in Java? Should I just loop and then send threads to sleep for some time?
What would be the proper way of doing it?
You should use the ScheduledThreadPoolExecutor
class, which does exactly that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With