Quantcast
Channel: How do servlets work? Instantiation, sessions, shared variables and multithreading - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Answer by Mahesh Balasubramanian for How do servlets work? Instantiation, sessions, shared variables and multithreading

$
0
0

As is clear from above explanations, by implementing the SingleThreadModel, a servlet can be assured thread-safety by the servlet container. The container implementation can do this in 2 ways:

1) Serializing requests (queuing) to a single instance - this is similar to a servlet NOT implementing SingleThreadModel BUT synchronizing the service/ doXXX methods; OR

2) Creating a pool of instances - which's a better option and a trade-off between the boot-up/initialization effort/time of the servlet as against the restrictive parameters (memory/ CPU time) of the environment hosting the servlet.


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>