Synchronization in JAVA

You should be aware of Synchronization if you are working on an application where multiple threads are accessing the same resources or else it will show you erroneous or unforeseen results. Imagine a scenario where you are doing the multiple transactions in your bank. I believe you don’t want one thread is updating your balance and in parallel, the other thread is reading your balance otherwise you will end up in error or unexpected results. Example 1: Public class HDFCBank { Protected long balanace =1000; Public void deposit( int amount) { this.balance = this.balance + amount; } } Assume if two threads, A and B are executing t...