Firstly you should decide what do you like about life-time of that
thread pool without being worry about calling shutdown. All your
examples have solutions to call shutdown which I described below...
Please read below....
[Try1] . By springframe work setup ThreadPool . In action class, use
fixedPool Future<String> f1 = fixedPool.submit(() -> { ...actions
such as send email, etc }); So, there will be NO shutdown in
action class fixedPool.shutdown(); will be maintained by
spring config?
You can set your bean `destroy-method` and call shutdown in that
method. e.g. <bean id="poolService" class="me.emi.PoolService"
init-method="initPool" destroy-method="shutdownPool">
[Try2] . Each user login session create one fixedPool . When user
logout, fixedPool.shutdown() What about if users do not call logout
action. Where and how the fixedPool to be shutdown? Is there a way
to auto shutdown after period of time?
You can write your own listener by implementing HttpSessionListener
and call shutdown in it's `sessionDestroyed` method. Please see [1].
[1] http://www.myjavarecipes.com/tag/session-timeout-handling-in-java/
Thank you very much Yasser. The information are very helpful!
I will try1 which can be used/shared by all login users or 2 used by per
login user session then.