> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> Subject: Re: session.isNew() not thread safe?
>
> Thus, you cannot guarantee that using the session object itself for
> synchronization (like doing "synchronized(session) { ... }"
> in your code will give you exclusive access to your session object.

Correct, which is another reason why Karl San Gabriel's suggestion was not only 
nonsense, but dangerous.

> I'm not entirely convinced this exclusive access is necessary,
> since mostly people are doing set/get attribute calls and those
> will be fine.

It's only necessary when you need to take an additional (usually one-time) 
action based on the presence of some attribute in the session; in that case, 
synchronization on something else common to the servlets of the webapp is 
necessary.

> You can't even throw an object into the session to be
> used as a monitor

Actually you can - you just need to do it with an HttpSessionListener when the 
HttpSession is first created, before any additional threads can get their paws 
on it.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to