I tried your approach, but it does not seems to working in concurrent access to 
methodA(). Let me explain, I ran test with two threads running almost parallel. 
Each thread making 100 calls to methodA(). At the end of the test the count 
should have increased by 200 but its not the case. Its always less than 200. 
When I looked deeper into the problem I found that two threads calling count() 
at same time (or before the current thread has written the new counter value to 
database) will read same counter value from the database. Thus both of them 
will result in writing same value in the database which is not right. There 
must be locking mechanism on the table or method which blocks others from 
access until current thread finishes the count() method. I tried synchronized 
but in vain.

I appreciate your help and hope to hear better solution from experts.

Murtuza

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995020#3995020

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995020
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to