java - Should single thread scheduled executor be used to schedule two tasks with different delays? -


in java program call executors.newsinglethreadscheduledexecutor(); create executor subsequently use schedule 2 tasks. these tasks have different fixed delays, this:

executor.schedulewithfixeddelay(task1, 0, 5000, timeunit.milliseconds); executor.schedulewithfixeddelay(task2, 0, 100000, timeunit.milliseconds); 

i tested portion of program smaller delays , worked expected. in production, however, stops after day, after week or without logging exceptions. on safe side , following advice given in related questions enclosed both tasks in

try {     dostuff(); } catch (throwable th) {     logstuff(); } 

the problem remained , checked if logging configured correctly. was.

in documentation of newsinglethreadscheduledexecutor() method mentioned that

tasks guaranteed execute sequentially, , no more 1 task active @ given time.

this suits me , don't understand why program exits without visible problems.

is type of executor suitable mentioned scenario? there pitfalls? may go wrong , remain unnoticed?


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -