Currently I have a ScheduledThreadPoolExecutor which can execute a callable at a fixed rate.
scheduledThreadPoolExecutor.scheduleAtFixedRate(callable, delay, waitNano, TimeUnit.NANOSECONDS);
My team wants to add some randomess into the waitNano. Currently it is 1000. But we want the wait second to be 900, 1100, 800, 1200, for example. The average wait time is still 1000 but the wait second is randomly distributed, (for example like a Bell curve).
I am wondering is this functionality already in java? If I have to write my own "scheduler" which has this random-waiting behavior, what do you guys suggest?
Thanks a lot!
Erben
Invoke another Runnable
at fixed schedules (for example 10 min) and let it configure random scheduler's next execution randomly still managing randomness
using schedule();
For example: first column shows execution of fixed scheduler which determines when to execute managed random scheduler
0 1
5 7
10 11
15 18
来源:https://stackoverflow.com/questions/22794010/java-schedule-a-callable-at-pseudo-fixed-rate-bell-curve-distribution-for-exa