为什么(javax.servlet。)不推荐使用SingleThreadModel? [英] Why is (javax.servlet.)SingleThreadModel deprecated?

查看:100
本文介绍了为什么(javax.servlet。)不推荐使用SingleThreadModel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 javax。 servlet.SingleThreadModel 是否已弃用?

Why is javax.servlet.SingleThreadModel deprecated?

推荐答案

javadoc 说明原因。 SingleThreadModel 旨在成为低负载并发的简单解决方案,但它甚至没有管理:

The javadoc says why. SingleThreadModel was designed to be an easy solution to low-load concurrency, but it didn't even manage that:


请注意,SingleThreadModel不会
解决所有线程安全问题。对于
示例,会话属性和静态
变量仍然可以通过
同时访问多个线程
上的多个请求,即使使用
SingleThreadModel servlet也是如此。
建议开发人员
采取其他方法来解决这些
问题,而不是实现这个
接口,例如避免使用
的实例变量或
同步访问这些资源的代码块

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.

如果它无法实现它的设计因为它不应该被使用。

If it can't achieve what it was designed for, it should not be used.

这篇关于为什么(javax.servlet。)不推荐使用SingleThreadModel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆