wood burning stoves 2.0*
The moose likes Servlets and the fly likes concurrency issue in non istance method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

concurrency issue in non istance method?

faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
Hello
i have command pattern with MVC pattern...
do get(){
command.execute()
}
in execute method
execute(){
calling a instance method of another class for accessing/delete/update DB
}
Should i use synchronize in class instance method which access/delete/update record

thanks
Faisal


}
Syed Saifuddin
Ranch Hand

Joined: Sep 01, 2003
Posts: 130
Assalaam-o-Alakum:
One way to solve ur problem is by using Synchronise but if have to deal with money transection then use ejb at the backend of servlet


Thank You & Best Regards,

Syed Saifuddin,
Senior Software Engineer

SAP Oracle AIX & Java Training
http://www.socialinet.com
faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
thanks...
but u do not understand my question.
my question is that, synchronize block is necessary for udating/delete/insert DB records in execute method...(the senario i give u)?
thanks
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
Synchronize would not be needed in this case if all you do is delete/insert/update database records as the db will not allow another DML SQL statement to execute until the other is finished.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

Hi faisal, not sure how this is a Servlets question, and not sure which forum would this thread be more appropriate in.
However, you should consider Synchronization as a way to keep one call to a method being run at one time. Meaning no other caller can call that method while the first caller is running.
This is different than transactions, which is database related, and basically states that one or more sql statements can run and either they all commit or they all rollback. So while one user has a transaction occuring, another can also have their own transaction running, and all concurrency issues are handled by the database.
With this in mind, I am just going to close this thread, and if you have more questions, please try to post them in the appropriate forum. Each forum has a topic, and posts in each forum should be about the topic.
Thanks
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: concurrency issue in non istance method?