[/url] [url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview
Class
JavaTM 2 Platform
Ent. Ed. v1.4
PREV CLASS NEXT CLASS
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
javax.servlet
Interface SingleThreadModelDeprecated. As of Java Servlet API 2.4, with no direct replacement.
public interface SingleThreadModelEnsures that servlets handle only one request at a time. This interface has no methods. 确保servlet每次只处理一项请求。接口不含方法。
If a servlet implements this interface, you are guaranteed that no two threads will execute concurrently in the servlet's service method. The servlet container can make this guarantee by synchronizing access to a single instance of the servlet, or by maintaining a pool of servlet instances and dispatching each new request to a free servlet. 如果servlet实现了该接口,会确保不会有两个线程同时执行servlet的service方法。 servlet容器通过同步化访问servlet的单实例来保证,也可以通过维持servlet的实例池,对于新的请求会分配给一个空闲的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. This interface is deprecated in Servlet API version 2.4. 注意:SingleThreadModel不会解决所有的线程安全隐患。 例如,会话属性和静态变量仍然可以被多线程的多请求同时访问,即便使用了SingleThreadModel servlet。建议开发人员应当采取其他手段来解决这些问题,而不是实现该接口,比如 避免实例变量的使用或者在访问资源时同步代码块。该接口在ServletAPI 2.4中将不推荐使用。
Version: $Version$ Author: Various
[/url][url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview
Class
JavaTM 2 Platform
Ent. Ed. v1.4
PREV CLASS NEXT CLASS
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Submit a bug or feature Copyright 2003 Sun Microsystems, Inc. All rights reserved.