On Wed, 24 Apr 2002, Galbreath, Mark wrote:

> Date: Wed, 24 Apr 2002 16:05:31 -0400
> From: "Galbreath, Mark" <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
> Subject: RE: Struts Actions are Singletons?
>
> On both the accessors and mutators?
>

Yes.

Take a simple form bean with only string and boolean properties (i.e. no
references to nested beans).  Put that form bean in request scope.  You
are now guaranteed that only your thread can access that form bean, and
you therefore don't have to synchronize anything.  (See the form beans in
the Struts example app for an illustration of this.)

If you have nested references to other beans, you have to go consider
whether *those* beans are referenced from anywhere else -- if they aren't,
then you are still thread safe.  If they are, you *may* have to
synchronize, depending on whether it can be mutated from multiple threads
or not.

> Mark
>

Craig


> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 24, 2002 3:56 PM
>
> >From a programming point of view, you can think of form beans in request
> scope just like you think of local variables -- there is a copy per
> thread, so you don't have to worry about synchronizing anything inside
> them (although you would if the form bean was saved in session scope).
>
> Craig
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to