Run java thread at specific times

Posted by rmarimon on Stack Overflow See other posts from Stack Overflow or by rmarimon
Published on 2010-03-13T03:19:37Z Indexed on 2010/03/13 3:27 UTC
Read the original article Hit count: 366

Filed under:
|
|

I have a web application that synchronizes with a central database four times per hour. The process usually takes 2 minutes. I would like to run this process as a thread at X:55, X:10, X:25, and X:40 so that the users knows that at X:00, X:15, X:30, and X:45 they have a clean copy of the database. It is just about managing expectations. I have gone through the executor in java.util.concurrent but the scheduling is done with the scheduleAtFixedRate which I believe provides no guarantee about when this is actually run in terms of the hours. I could use a first delay to launch the Runnable so that the first one is close to the launch time and schedule for every 15 minutes but it seems that this would probably diverge in time. Is there an easier way to schedule the thread to run 5 minutes before every quarter hour?

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading