为什么是 javax.servlet.SingleThreadModel
已弃用?
最佳答案
javadoc说为什么。 SingleThreadModel
旨在成为低负载并发的简单解决方案,但它甚至没有做到这一点:
Note that SingleThreadModel does not solve all thread safety issues. For example, session attributes and static variables can still be accessed by multiple requests on multiple threads at the same time, even when SingleThreadModel servlets are used. It is recommended that a developer take other means to resolve those issues instead of implementing this interface, such as avoiding the usage of an instance variable or synchronizing the block of the code accessing those resources.
如果它不能达到它的设计目的,就不应该使用它。
关于java - 为什么不推荐使用 (javax.servlet.)SingleThreadModel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2551999/