java - 为什么不推荐使用 (javax.servlet.)SingleThreadModel?

标签 java multithreading servlets

为什么是 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/

相关文章:

java - 无法使用 WebFlux 在 Spring Boot 中使用 H2 和 R2DBC 创建 ConnectionFactory 错误

java - 插入初始数据 JPA

python - Python 的关闭过程设置模块全局变量在哪里记录?

java - 支柱 1 : Entry ActionForm inputs from any Action class

java - 如何填充缓存并保持更新

java - 无法使用 VisualVM 连接到 Tomcat

java - 如何从 Firebase 获取所有 Childs 的 Java 对象的 ArrayList

c# - 程序在等待线程退出时不会增加进度条

python - TensorFlow 和线程

java - Java 9 也适用于 WAR 文件吗?