1
votes

Within a Tomcat 8 server, we have several WAR projects that need thread pools to execute tasks (schedulers and parallel processing for faster performance specifically).

As each pool handles their own threads, it ended up adding too many threads to the container, so the evident question came up: is it possible to somehow share a single thread pool with several war projects within Tomcat?

The pools are a mix between Spring's schedulers and the standard Java ThreadPoolExecutor, but I guess they could be standardized into a single type if needed.

PS: Does this actually help The Executor (thread pool) If so, how?

1
First, if you go over Tomcat capacity you may be should look at your architecture to be sure that you can't reduce the quantity of threads. - Zorglube
@Zorglube could you please explain and/or rephrase a bit your comment please, I don't actually understand what you meant. - gvasquez
I just mean, if you have so many Threads that Tomcat can't handel it : you should rework your software architecture to be realy sure that you can't do the job using less thread. - Zorglube

1 Answers

1
votes

You can configure a single ThreadPool as a global JNDI resource and then use ResourceLinks to make that resource available to as many or as few web applications as you require. You'll probably need to code up a simple custom resource factory to make this work.

Tomcat's JNDI documentation provides a worked example for a simple factory.