What is design principle behind Servlets being Singleton
Posted
by
Sandeep Jindal
on Stack Overflow
See other posts from Stack Overflow
or by Sandeep Jindal
Published on 2012-06-28T15:01:36Z
Indexed on
2012/06/28
15:16 UTC
Read the original article
Hit count: 297
A servlet container "generally" create one instance of a servlet and different threads of the same instance to serve multiple requests. (I know this can be changed using deprecated SingleThreadModel and other features, but this is the usual way).
I thought, the simple reason behind this is performance gain, as creating threads is better than creating instances. But it seems this is not the reason. On the other hand, creating instances have little advantage that developers never have to worry about thread safety.
I am trying to understand the reason for this decision over the trade-off of thread-safety.
© Stack Overflow or respective owner