Reputation: 652
I'm using spring state-machine in a java application. To move between states we should use some events (called them Timer Event). It seems a thread is in charge to managing the timers that is set to determine when a movement between states will be occurred (definitely the state-machine will decide based on timers if nothing happen in a state that we are in). After adding a timer event to a transition (using Papyrus for defining state-machine), I see a remaining live thread even after main method completes. I have two questions; first, what is this thread (I mean, this thread is the same one that manages timer), and second, how can i terminate the thread at the end of my work?
Upvotes: 0
Views: 1175
Reputation: 2646
Timers are scheduled via Spring TaskScheduler
and with annotation based JavaConfig default instance of ConcurrentTaskScheduler
is created. This is done in StateMachineCommonConfiguration
If you want to modify this you can provide your own TaskScheduler
either by overriding bean with name taskScheduler
of use other machine configuration methods to set it. Default ConcurrentTaskScheduler
indeed is a based on single-thread executor which is what you see. These are discussed more in a Spring Framework documentation.
Upvotes: 0