Turn from: Original: http://blog.csdn.net/luoweifu/article/details/46613015
Author: Luoweifu
Synchronized is a key word in Java and is a synchronous lock. It modifies objects in the following ways:
1. Modify a code block, the modified code block is called the synchronous statement block, its scope is the curly braces {} In the code, the object is to call the object of this block of code;
2. Modify a method, the modified method is called the synchronous method, its scope is the whole method, the object is to call the object of this method;
3. Modify a static method whose scope of action is the entire static method, and the object of the action is all objects of this class;
4. Modify a class whose scope of action is synchronized the part enclosed in parentheses, and the object of the principal is all objects of the class.
Usage of synchronized in Java