As I understand the problem, we want to use non-daemon threads in
TimerServiceImpl, have an empty pool of threads when there are no
timers scheduled, and avoid unnecessary creation/destruction of threads
if a timer is scheduled.
This fix sets the core thread pool size to zero (so no threads are left
hanging about if there is no work) then adjusts the keep alive time
for the thread pool when the timer services goes from having nothing
scheduled to something scheduled and vice-versa (this avoids unnecessary
thread creation/destruction when there is a timer scheduled - but allows
threads to be expired when there are no timers scheduled).
As I understand the problem, we want to use non-daemon threads in TimerServiceImpl, have an empty pool of threads when there are no timers scheduled, and avoid unnecessary creation/destruction of threads if a timer is scheduled.
This fix sets the core thread pool size to zero (so no threads are left hanging about if there is no work) then adjusts the keep alive time for the thread pool when the timer services goes from having nothing scheduled to something scheduled and vice-versa (this avoids unnecessary thread creation/destruction when there is a timer scheduled - but allows threads to be expired when there are no timers scheduled).
Fixes #7