Thread-safe Servlets

May 29, 2008 at 6:32 am (Uncategorized)

Identify which attribute scopes are thread-safe:

  1. Local variables Yes, thread-safe
  2. Instance variables Not thread-safe
    Since a single servlet instance may be handling multiple service requests at any given time.
  3. Class variables Not thread-safe
    Since multiple servlets and /or service requests may try to access a class variable concurrently.
  4. Request attributes Not thread-safe
    See
    the quote below.
  5. 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
  6. Context attributes Not thread-safe
    Since the same context object can be accessed concurrently by multiple servlets and their service requests

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.