title: Volatile keyword - is it the only way to protect a value across threads?
body: <p>In Java, the <code>volatile</code> keyword is for direct read and write from main memory so that reads or writes won't be lost if multiple threads are accessing a variable.</p>
  
  <p>Without using <code>volatile</code>, is there any other way to achieve this functionality? I came across this question but couldn't figure out a solution. </p>