摘要
由于Servlet在服务器端事务处理方面的优异表现,在许多的Web应用中,它仍然是不可或缺的。在默认情况下,Servlet是以单实例多线程方式进行工作的,这就要求在用Servlet构建Web应用时重点考虑其线程的安全性。文章从一个实际的Servlet用例入手,就安全性问题展开了深入的分析,并得出其中实例变量不正确的使用是造成Servlet线程不安全的重要原因的结论,同时还就这一问题给出了几个供参考的解决方案。
Because of Servlet's good performance in server-side transaction processing, it is still indispensable in many Web applications. Servlet works in the way of single instance and multiple threads by default, so the safety of its threads should be considered emphatically in using Servlet to construct Web applications. Starting with a real Servlet case, the safety problem is deeply analyzed, and the conclusion is drawn that the incorrect use of instance variable is the significant cause of making Servlet threads unsafe, also several solutions to this problem are given for reference.
出处
《计算机时代》
2010年第5期17-19,共3页
Computer Era