More than one Singleton in one servlet container (Tomcat)

I have my own environment for creating a Java application, and within this framework, I create my own Threadpool artist service, which is singleton. Thus, every web application using my framework will create 1 Threadpool executor at startup to use it internally.

My questions:

  • Suppose I deploy 2 web applications in one Tomcat, will these 2 stream pools interfere with each other?
  • Is it possible when a thread from the 1st web application will access Threadpool from the second web application or vice versa?
  • Do I need to create one Threadpool service for all my web applications that are in the same servlet container, instead of one for each web application?

Thanks.

+4
source share
1 answer
  • Not. Webapps must be isolated by ClassLoader in Tomcat, so each must have its own singleton instance.
  • While the answer to # 1 is actually not, then the answer to this question is also missing.
  • Probably no.

As an aside, I understand that, as a rule, Java EE web applications should not create new threads.

+1
source

Source: https://habr.com/ru/post/1494848/


All Articles