Alessio Punturo Alessio Punturo - 7 months ago 9
Java Question

How to run an algorithm every x minutes on a Server?

I've created a clustering algorithm in Java that reads from a collection in a Mongo database, makes its computations and then writes to a new collection in the same database. Now, I need this algorithm to run every 30 minutes in the server. What could I use to do so?

Answer

If you're using JavaEE, you could use the @Schedule annotation.

Take a look at the API here. It saves you from using a dependency in your project.


Update:

If you're using JavaSE, maybe a Timer can help you.