Quoting Jerry Jalenak <[EMAIL PROTECTED]>:

> Holiday Greetings to All!
> 
> Quick design question - Is it possible to synchronize an application-scoped
> object between two servlets within the same web application?  I have a
> servlet that I have written that maintains a List object that is stored in
> application scope.  This servlet basically creates a new List, then replaces
> the existing one (uses the same name for the object).  My second servlet
> (Struts) simply accesses this List in a read-only fashion - no updates.  I
> can write a basic spin-lock type of mechanism to ensure that my Actions do
> not try to access this List while my first servlet is replacing the object,
> but I'm wondering if there is an easier approach, possibly using a
> synchronized block using the application object....
> 
> Comments?
> 

Synchronizing on the List instance won't help much, because of the way you're
replacing the old one with a new one -- but it's probably unnecessary as well,
since the servlet reading the old List and the servlet creating the new List
are never manipulating the same object instance.

If the servlet doing the modifying was doing it "in place" on the existing List
instance, then synchronizing on that instance would indeed be appropriate.

> TIA!
> 
> Jerry Jalenak

Craig


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

Reply via email to