• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transactions and Synchronise blocks

 
faisal khan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello..
I want to know that where to use synchronise blocks , and what is the difference between handling transactions and synchronosed blocks.
Thanks
Faisal Ishaque
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"faisal"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Just add your last name to your profile.
Also you posted your question in the Servlets forum. Your question isn't really about Servlets at all, it is really a Java in General type question. I am going to move this thread to that forum.
But, for an answer, a Synchronized method only allows one caller at a time to call the method, so if two calls are made at the same time, one of the calls will have to wait for the other to finish first.
Now a transaction is an atomic process. Meaning all the code within the transaction completes, or none of it is allowed to complete. In the database world, say you are adding three new records within this transaction, if any one of those records fail to add, then none of the three records are added.
Thanks! and welcome to the JavaRanch!
Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic