*
The moose likes Beginning Java and the fly likes Transactions and Synchronise blocks 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 » Beginning Java
Bookmark "Transactions and Synchronise blocks" Watch "Transactions and Synchronise blocks" New topic
Author

Transactions and Synchronise blocks

faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
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

Joined: Feb 05, 2001
Posts: 17258
    
    6

"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


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: Transactions and Synchronise blocks