struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject RE: Struts Actions are Singletons?
Date Wed, 24 Apr 2002 20:29:33 GMT

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

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


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


> -----Original Message-----
> From: Craig R. McClanahan []
> 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:   <>
> For additional commands, e-mail: <>

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

View raw message