title: thread local and context switch
body: <p>I'm got some C++ code making use of thread local storage, each thread has a vector it can push data into.   </p>
  
  <p>I use TLS to store an index ID per thread, this can be used to look up which vector to push data into. It then executes a fair amount of code which pushes data into the vector.</p>
  
  <p>What I'm wondering is if it is possible that the OS might reschedule my code to execute on a different thread after it has acquired the pointer to the thread local object. (So far the code executes fine and I have not seen this happen).  But if it were possible, this would seem certain to break my program, since it would now be possible for two threads to have the same object.  </p>
  
  <p>Assuming this is true, this seems like it would be a problem even for any code that uses TLS of any complexity, is TLS only intended for simple objects where you don't take the address?</p>
  
  <p>Thanks!</p>