Java / Java Multithreading
Difference between synchronized and volatile keyword in Java.
Volatile keyword is used on the variables and not on method while synchronized keyword is applied on methods and blocks not on variables.
Volatile does not acquire any lock on variable or object, but synchronized statement acquires lock on method or block in which it is used.
Volatile does not cause liveness problems such as dedlock while synchronized May cause as it acquires lock.
Volatile usually do not cause performance issues while synchronized block may cause performance issues.
More Related questions...