File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

concurrency issue in non istance method?

faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
i have command pattern with MVC pattern...
do get(){
in execute method
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


Syed Saifuddin
Ranch Hand

Joined: Sep 01, 2003
Posts: 130
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
faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
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)?
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
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. - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: concurrency issue in non istance method?
It's not a secret anymore!