Help the world stop coronavirus! Stay home!

Prev Next

Java / volatile

Difference between synchronized and volatile:

Synchronized block applies only to object.volatile keyword can be applied to Object or primitive types.
Synchronized block does not work on null. Attempting to synchronize on a null object will throw a NullPointerException. volatile variables can be null.
synchronized blocks other threads while one thread is accessing the block.volatile does not block any threads.
synchronization occurs when you enter a synchronized block.synchronization occurs when a volatile variable is accessed.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

Java ThreadLocal

Comments & Discussions