Open zmjzmjzmj8 opened 4 years ago
We using StateMachineBuilder to build StateMachine for every each request. After running for a while, we found that the stateMachine created lots of threadPool without recycled but stay in waiting state.
Could you please help and give practices?thanks
You could provide your own taskExecutor & taskScheduler like:
config.withConfiguration()
.taskExecutor(ThreadPoolTaskExecutor().also {
it.initialize()
}).taskScheduler(ConcurrentTaskScheduler(Executors.newScheduledThreadPool(size)))
A request will build a StateMachine
When I request many times, many thread pools are created.
That my code
StateMachineBuilder.Builder<S, E> seBuilder = StateMachineBuilder.builder();
seBuilder.configureConfiguration().withConfiguration().machineId(System.currentTimeMillis() + "")
.listener(listener())
.beanFactory(beanFactory);
configure(seBuilder.configureStates());
configure(seBuilder.configureTransitions());
StateMachine<S, E> stateMachine = seBuilder.build();