Identify which attribute scopes are thread-safe:
-
Local variables Yes, thread-safe
- Instance variables
Not thread-safe
Since a single servlet instance may be handling multiple service requests at any given time. - Class variables
Not thread-safe
Since multiple servlets and /or service requests may try to access a class variable concurrently. - Request attributes
Yes, thread-safe
Since the request object is a local variable - Session attributes
Not thread-safe
Since sessions are scoped at the web application level, hence the same session object can be accessed concurrently by multiple servlets and their service requests - Context attributes
Not thread-safe
Since the same context object can be accessed concurrently by multiple servlets and their service requests
posted on 2006-10-08 12:41
Sun River 阅读(248)
评论(0) 编辑 收藏 所属分类:
Servlet & Jsp