Replies: 3 comments 3 replies
-
On behalf of @esanchezros (copied from #428 (comment)): Hi @kotari4u, I don't quite understand your problem. The Can you create a sample project illustrating the issue you're having? Thanks |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. I tried to create a sample project but could not replicate issue. We will dig further and get back if we can replicate. Thank you.. |
Beta Was this translation helpful? Give feedback.
-
I spent a little time digging into this, as I also have a Spring application with beans wrapping multiple Lets look at
Here static just means the This
This means that if the non-static The A smal warning: When reading the code, the intention of Why static threads are bad
In the old days our Tomcat would run for weeks, but we would deploy our application continuously, and every time we did we would get this warning
In normal applications you mark you thread as a daemon, so it does not prevent the JVM from shutting down. This works because the JVM and application have the same lifecycle. When you have a container based system with multiple class loaders, unstopped threads will prevent GC of anything that is reachable by that thread. |
Beta Was this translation helpful? Give feedback.
-
This is continuation for bug #428. It has been suggested to post the query here. I can post the latest response here to continue the discussion
#428
Thank you and appreciate for the quick response.
I cannot have one ThreadedSocketInitiator and have N number of fix sessions, due to few design constraints. I need two separate ThreadedSoketInitiator and when I initiate two beans in different/same spring context for two different clients, then I see problem at the below code, where we are scheduling a fixed task.
Lets say one ThreadedSocketInitiator comes and schedule a fixed task for Vendor 1 connectivity and when we create another bean it will overwrite the scheduled task because "SCHEDULED_EXECUTOR" is private "static" final variable. As it is static only one executor service is allowed and only one task can be run. If it non-static private final then we will have two executor services and its own scheduled jobs. Any reason it has to be "static". Removing "static" here will solve this issue. Not sure if anyone else faced this problem. But if we create two ThreadedSocketInitiator's and connecting to two different clients from the same class loader then we would see this issue
protected void startSessionTimer() {
Runnable timerTask = new SessionTimerTask();
if (shortLivedExecutor != null) {
timerTask = new DelegatingTask(timerTask, shortLivedExecutor);
}
sessionTimerFuture = SCHEDULED_EXECUTOR.scheduleAtFixedRate(timerTask, 0, 1000L,
TimeUnit.MILLISECONDS);
log.info("SessionTimer started");
}
Beta Was this translation helpful? Give feedback.
All reactions