My understanding of "volatile" have been that changes made to a volatile variable by one thread is visible to another thread (basically all threads see a consistent value of the variable) and that seems to be right as well if I read JLS or other answers.
But when I read answer to this question then I get confused because as per me marking the variable as volatile will ensure that other threads will read the correct value of boolean.
Please correct me if I am missing something.