Banking synchronized Multi-Threaded Demo

Two threads are constantly transferring funds (with different amounts) between some customer's checking and savings account.  If there are no thread problems, the total amount in the two accounts should be constant.  However it is likely that over time the customer will lose (or gain) money.

To fix the problem, the transfer must be atomic.  This can be done by uncommenting the keyword synchronized in the transfer() method declaration.  Try it and see!

    View Java applet source

Send comments and mail to the WebMaster.