openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "roger.keays" <roger.ke...@ninthavenue.com.au>
Subject race condition in a transaction?
Date Fri, 05 Jan 2007 00:09:02 GMT

Hi,

I'm just wondering if the following code could be subject to a race
condition when accessed by many threads

em.getTransaction().begin();
bean.setCount(bean.getCount() + 1);
em.getTransaction().commit();

My understanding is that it would be possible here for two threads to set
the same value for the new count (given that each thread has a different
em). Is that correct?

Do I have to use an UPDATE query to make this function as expected?

Thanks,

Roger
-- 
View this message in context: http://www.nabble.com/race-condition-in-a-transaction--tf2922964.html#a8170503
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Mime
View raw message