Win a copy of Functional Reactive Programming this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic

concurrency issue in non istance method?

 
faisal khan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
faisal khan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 862
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
    Bookmark Topic Watch Topic
  • New Topic