struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Struts Actions are Singletons?
Date Wed, 24 Apr 2002 17:43:26 GMT

Can someone explain why these are created as singletons in the first place?

Eddie Bush <> on 04/24/2002 01:49:35 PM

Please respond to "Struts Users Mailing List"

To:   Struts Users Mailing List <>
Subject:  Re: Struts Actions are Singletons?

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'" <>
Sent: Wednesday, April 24, 2002 8:59 AM
Subject: RE: Struts Actions are Singletons?

> > -----Original Message-----
> > From: Abhishek Srivastava []
> > 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
> synchronize access to them, as they could be accessed by many threads
> simulataneously.
> Hope this helps.
> Cheers,
> Laird
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure.  If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message