java cron solution with completion checking -


i looking simple cron-type solution java-application.

i looked @ cron4j, can set method execute, example every 5 minutes.

only, have custom requirement that, if previous method call still running, should not start simultaneous call, skip call , try again in 5 mins, etc --- i.e. want make sure never run 2 threads same job in parallel. if previous method-call has completed, should new 1 start.

what easiest/most stable way implement requirement in java? (doesn't have cron4j if there better way)

i prefer cron4j because believe it's lightweight , easy use. use application-scoped method perform synchronization.

for instance, if application distributed, jobs details must stored on shared storage, database. in database, can set flag (i.e. column value each job details) indicates if job being executed. , then, next execution time (i.e. column value, , find having column holding next execution flag helpful, should give try if haven't already) should modified adding whatever offset like.

if application isn't distributed, can use synchronized static method or static reentrantlock instance control synchronization.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -