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 閱讀(258)
評論(0) 編輯 收藏 所屬分類:
Servlet & Jsp