Answer the question
In order to leave comments, you need to log in
Servlets, multithreading, how does it work?
Good afternoon,
Suppose I wrote a servlet (or made a web service using @RequestMapping in spring) and run it in Tomcat.
Suppose there were 10k users.
Answer the question
In order to leave comments, you need to log in
On startup, Tomcat will create a thread pool and a servlet instance. When requests come in, servlet methods will run on threads from the pool. The servlet is not destroyed until the end of the server.
You can create threads yourself, but why? Especially when using Spring, which provides a whole bunch of convenient high-level abstractions for convenient work with asynchronous tasks.
With caching, you need to be extremely careful, since this is exactly the area in which you can run into multithreading problems.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question