struts1 action线程安全问题

来源:互联网 发布:淘宝erp 编辑:程序博客网 时间:2024/05/16 09:54
Struts1的action是单例的,也就是线程不安全的。假设在理想的状态下,如果,两个人同时访问了某个action的同一个方法,是不是会出错呢?
1. 全局变量会有影响
2. 局部变量没有影响
struts user guide里有: Only Use Local Variables - The most important principle that aids in thread-safe coding is to use only local variables, not instance variables , in your Action class. 译:只使用用局部变量。--编写线程安全的代码最重要的原则就是,在Action类中只使用局部变量,不使用实例变量。
原创粉丝点击