synchronized methods prevent more than one thread from accessing an object's critical method code simultaneously.
The synchronized modifier applies only to methods and code blocks, not variables or classes.
synchronized methods can have any access control and can also be marked final.
Each object has just one lock.
Not all methods in a class need to be synchronized.
A class can have both synchronized and non-synchronized methods.
If a thread goes to sleep, it holds any locks it has.
While only one thread can be accessing synchronized code.
Multiple threads can access the same object's unsynchronized code.
The main static methods in the Thread class are sleep, yield, and currentThread.
If you have a synchronized method in a class, a subclass with an overriding method does not have to declare it as synchronized.
The synchronized keyword affects only the code block in the original class.
|