Why do we use synchronized method in Java?
Synchronized methods enables a simple strategy for preventing the thread interference and memory consistency errors. If a Object is visible to more than one threads, all reads or writes to that Object's fields are done through the synchronized method.
How do you make a method synchronized in Java?
You just add the synchronized keyword to the method declaration, like this: public synchronized void someMethod()... This code tells Java to place a lock on the object so that no other methods can call any other synchronized methods for the object until this method finishes.