> -----Original Message----- > From: Behrang Saeedzadeh [mailto:[EMAIL PROTECTED] > Sent: Tuesday, December 14, 2004 3: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?
No.. you need to syncrhonize on the lock. Check the java tutorials on multi-threaded architecture for details. A better solution might be to use one of the solutions discussed on the list on implementing a progress bar, or please wait page when the user clicks the link. http://www.mail-archive.com/cgi-bin/htsearch?config=user_struts_apache_org&restrict=&exclude=&words=progress+b > > 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]