This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes Synchronized Example with Bank Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Synchronized Example with Bank" Watch "Synchronized Example with Bank" New topic
Author

Synchronized Example with Bank

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
Hi Friends, i have searched in google but not clear. can you bank example with synchronized keyword
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What do you mean by "bank example with synchronized keyword"?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I could nt understand the following clearly.so i ask you another example

Let's use a bank application program as an example. Assuming that the program has multiple threads running, with each thread connecting one ATM system, and you have a saving account in the bank with $100.00, now you and your friend are going to two different ATMs at about the same time, and trying to withdraw $50.00 from your account, what do you think it will happen?

Time 01:01 02:01 03:01 04:01
+----------+---------+---------+-------
Thread 1 Get Set
Action You Account Account You
Withdraw Balance Balance Receive
$50.00 $100.00 $50.00 $50.00

Time 01:02 02:02 03:02 04:02
-+----------+---------+-----------+------
Thread 2 Get Set
Action Friend Account Account Friend
Withdraw Balance Balance Receive
$50.00 $100.00 $50.00 $50.00

Time 01:01 02:01 03:01 04:01
-----------++--------++--------++------
Account $100.00 $100.00 $50.00 $50.00
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronized Example with Bank
 
Similar Threads
Synchronized block K&B problem
Ending of session
WA #1.....word association
WA #2 ..... word association
Class cast exception