|
Yes , I got a reason for making the two as different .
Look we have scenario like this say we have two threads
First thread need to set the variable for the next thread
Second thread comes & checks the variable & finds it's not set , it return without doing it's task
Only volatile can solve this problem
So the conclusion is volatile is not a replacement for synchronization and vice versa
|