Monday, 30 January 2017

Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=Pr7NlI7nbFg&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
Java Tutorial: Java Synchronization (Why we use Synchronization[Bank] | Synchronization in java) 
BankAccount.java
public class BankAccount
{

    private int accountNumber;
    private double accountBalance;
    
    private AccountDAO dao;

    public synchronized boolean deposit(double amount)
    {
        double newAccountBalance;
        /*
         * Get the current balance from DB table.
         */
        accountBalance = dao.getCurrentAccountBalance(accountNumber);
        
        if (amount < 0.0)
        {
            /*
             * Can not deposit a negative amount.
             */
            return false; 
        }

        else
        {
            newAccountBalance = accountBalance + amount;
            /*
             * Update the new balance in the DB table.
             */         
            dao.updateAccountBalance(newAccountBalance);
            return true;
        }

    }
}
AccountDAO.java
public class AccountDAO
{

    public double getCurrentAccountBalance(int accountNumber)
    {
        /*
         * Code to get the current balance from DB table.
         */
        return 0;
    }

    public void updateAccountBalance(double newAccountBalance)
    {
        /*
         * Code to update the new balance in the DB table.
         */ 
        
    }

}
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/SynchronizationDemo_Bank_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/28b772df8f5b4b9e60fd873726243fc258cd34a2/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • 9 comments:

    1. Usually I do not read post on blogs, but I would like to say that this write-up very forced me to try and do it! Your writing style has been surprised me. Great work admin.Keep update more blog.
      Pest Control in Chennai

      ReplyDelete
    2. it was helpful to us to learn more and useful to teach others.This like valuable information is very interesting to read.


      Best Dental Clinic in Tambaram

      ReplyDelete
    3. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
      SEO Company in India
      Digital Marketing Company in India

      ReplyDelete
    4. You have shared a very useful and informative blog. Thank you for sharing the blog with us. please keep on updating.
      VMwareTraining in Chennai

      ReplyDelete
    5. Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post buddy..
      SEO Company in Chennai

      ReplyDelete
    6. Excellent and very cool idea and the subject at the top of magnificence and I am happy to this post..Interesting post! Thanks for writing it.What's wrong with this kind of post exactly? It follows your previous guideline for post length as well as clarity.
      Web Development Company in India

      ReplyDelete
    7. thanks for shared wonderful information of giving best information.its more useful and more helpful. great doing keep sharing
      Germany Education Consultants in Chennai

      ReplyDelete

    8. Truely a very good article on how to handle the future technology. After reading your post,thanks for taking the time to discuss this content.


      Digital Marketing Company in Chennai

      ReplyDelete

    9. هل تعبت من الحشرات المنزليه وخاصة الفئران والصاصير؟ نحن نوفر لك افضل خدمات مكافحة الحشرات والقضاء عليها بما يوفر لك راحت البال منها
      شركة مكافحة الفئران بالرياض
      شركة رش مبيدات بالخرج
      شركة مكافحة حشرات بالخرج
      شركة مكافحة حشرات بالرياض




      ReplyDelete

    Google+ Followers

    Google+ Badge