mqlight / java-mqlight

This Java package provides the high-level API by which you can interact with the MQ Light runtime.
Apache License 2.0
10 stars 9 forks source link

Keep threads alive indefinitely if TimerServiceImpl has work to do #12

Closed prestona closed 9 years ago

prestona commented 9 years ago

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