At one company I used to work on, there was no version control system, and there were a bunch of source code files. If you wanted to alter a file, you had to walk to a white board, and place a Red Dot on the file you were going to alter. After you are done, you had to erase the red dot to signify that you were no longer editing that file. Synchronization is very similar conceptually. You mark an object as being in use, and any other thread wanting to access that object will have to wait till it is released.
Synchronization is done by declaring a method or a code block synchronized .
If a thread invokes a synchronized method on an object, that object is locked. This means that access to that object is sequential in time. Let s consider an example. There are three threads that need to synchronize to access some data. One thread waits for the checking account balance to change from zero.