title: Java HashMap race condition
body: <p>I am trying to find out if there is going to be any race condition in this piece of code. If the key weren't 'Thread.currentThread' then I would think yes. But since the thread itself is key, how is it possible to have a race condition? No other thread can possibly update the same key in the HashMap!</p>
  
  <pre><code>public class SessionTracker {
  
       static private final Map&lt;Thread,Session&gt;  threadSessionMap = new HashMap&lt;Thread,Session&gt;();
  
       static public Session get() {
           return threadSessionMap.get(Thread.currentThread());
       }
  
       static public void set(Session s) {
           threadSessionMap.put(Thread.currentThread(),s);
       }
  
       static public void reset() {
           threadSessionMap.remove(Thread.currentThread());
       }
  }
  </code></pre>