What are synchronized methods and synchronized statements?Synchronized methods are utilized to control the access to an object especially in multithreaded programming. After acquiring the lock for an object, the thread only executes the synchronized methods.
Synchronized statements are similar to that of the synchronized methods. The variation is that the synchronized methods are part of a class and explicitly be invoked by another method. Whereas a synchronized statement is executed by its containing method which in turn accessed by another method.
|