Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

concurrency issue in non istance method?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


}
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic