This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Transactions and Synchronise blocks" Watch "Transactions and Synchronise blocks" New topic

Transactions and Synchronise blocks

faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
I want to know that where to use synchronise blocks , and what is the difference between handling transactions and synchronosed blocks.
Faisal Ishaque
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
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!

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Transactions and Synchronise blocks
It's not a secret anymore!