You might be able to get away with simply adding 'synchronized' to the
execute method's signature.
synchronized public ActionForward execute(...) {
updateXml();
}
private void updateXml() { ... }
The lock/key threading techniques have to do with, I think, a more
complex threading issue than the one you've presented.
- Dave
> -----Original Message-----
> From: Behrang Saeedzadeh [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 14, 2004 4:34 PM
> To: [EMAIL PROTECTED]
> Subject: Preventing concurrent execution of an Action
>
> Hi
>
> I've an action that creates an XML file on the server. It's executed
> by clicking on a link. I don't want multiple instances of it to be
> executed concurrently.
>
> Does an approach like the following work?
>
> public class UpdateXmlAction ...
> {
> private static final boolean locked;
>
> public void execute(...) {
>
> if (UpdateXmlAction.locked) {
> return;
> }
>
> Synchronized(UpdateXmlAction.class) {
> locked = true;
> updateXml();
> locked = false;
> }
>
> }
> }
>
> Thanks in advance.
>
>
> --
>
> Behrang Saeedzadeh
> http://www.jroller.com/page/behrangsa
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]