struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eddie Bush <ekb...@swbell.net>
Subject Re: Struts Actions are Singletons?
Date Wed, 24 Apr 2002 17:49:35 GMT
The suggestion I've seen on this is to move all instance variables to the
session.  Of course, that doesn't guarantee thread-safety either - but it
comes a whole lot closer.

----- Original Message -----
From: "Nelson, Laird" <Laird.Nelson@FMR.COM>
To: "'Struts Users Mailing List'" <struts-user@jakarta.apache.org>
Sent: Wednesday, April 24, 2002 8:59 AM
Subject: RE: Struts Actions are Singletons?


> > -----Original Message-----
> > From: Abhishek Srivastava [mailto:abhishes@hotmail.com]
> > And to make it thread safe I have use "synchronize" blocks of
> > code which can
> > cause all the requests to get queued up. (Java has lock per object,
> > therefore if my code had 2 synchronized blocks, then the 2nd
> > block would
> > lock up even when the first one is being executed.)
> > Isn't this bad for performance?
>
> Right; you should ensure that your Action class does not define or use
> instance variables of its own, since they will, by definition, not be
> request-specific.  If you find you *must* define them, then yes, you
should
> synchronize access to them, as they could be accessed by many threads
> simulataneously.
>
> Hope this helps.
>
> Cheers,
> Laird
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message