title: volatile Thread object and thread object comparison in java
body: <p>I am not much familiar with volatile keyword and thread. I have a piece of code that does comparison using ==. I got suggested these objects should be compared with equals.</p>
  
  <pre><code>while(pollingThread == thisThread)
  </code></pre>
  
  <p>where pollingThread defined as:<code>private volatile PollingThread pollingThread;</code></p>
  
  <p>and PollingThread is <code>private class PollingThread extends Thread</code></p>
  
  <p><code>thisThread</code> declared as <code>Thread thisThread = Thread.currentThread();</code></p>
  
  <p>I have performed many String comparisons using equals and I know the rules. But I was just curios if changing the <code>==</code> operator with <code>.equals</code> method cause any issue. (I dont know what issue I gonna face)</p>