This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes How can i avoid con-current access in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How can i avoid con-current access in java" Watch "How can i avoid con-current access in java" New topic
Author

How can i avoid con-current access in java

Guy Belpa
Ranch Hand

Joined: Nov 21, 2004
Posts: 41


IF my english wrong sorry.

see this code,
(this is not real code.. this is only


What i want is avoid con-current access to this method.
Becase Currently sometimes this method returns same "currentstID"
for two users!!! which spoil all program flow.

i tried



and



But no work??

Please help!!!


(this is web based (struts) application hosted in Weblogic server)

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20049
    
  30

I'm moving this to JDBC.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Guy Belpa
Ranch Hand

Joined: Nov 21, 2004
Posts: 41
problem not clear?
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42956
    
  73
PatienceIsAVirtue

Making that method synchronized will only work if there's only a single instance of the class that contains the method. If there are several instances then the code needs to synchronize on the same object for all instances - maybe the Class object of that class.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can i avoid con-current access in java
 
It's not a secret anymore!