struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Crossley <jcross...@ifleet.com>
Subject Re: Hi Folks, 2 questions about Actions and their instance
Date Mon, 01 Apr 2002 17:37:35 GMT
theron.kousek@webmd.net writes:

> > I don't know, but it doesn't matter.  You should always assume that
> > any specific instance of an Action class could potentially serve multiple
> > threads at once.  Or else what's the point of putting your app on the
> > web?  ;-)
> 
> Reason I brought this up is that I plan to use mysql.    Mysql has those
> AUTO INCREMENT fields and I want to insert a record and immediately call
> last_index_id()  to get the newly inserted row.    If I do this is just one
> and only one action, I may be able to prevent a timing/race condition by
> which last_index_id() may accidentally be returned from the wrong insert.
> I definitely want to prevent that from happening.

Then have the method that inserts the record return the last_index_id
and declare that method to be synchronized.  If that's all the
Action's perform method does, then you can declare it to be
synchronized, but it's probably cleaner to put the method on some sort
of DAO class.

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message