How to perform long tasks?

Artists are commonly used when it comes to (short) tasks, but what is the best way to solve long-term tasks, for example. tasks to be performed throughout the life of the application?

Let's say I have an application in which a task running in a separate thread polls the directory for changes every X seconds. This task should never stop polling if the application does not shut down. How do I start and manage this?

Could there new Thread(theLongRunningTask).start()be such a bad option?

+5
source share
1 answer

Executors, scheduleAtFixedRate. , , . ThreadFactory, daemon. , - , Timer API. Timer , " ". , .

+5

All Articles