title: Method local variables and stack and heap
body: <p>While reading on Thread Safety I came across this issue. 
  If I'm correct method local Primitives and object references lives inside a stack and actual objects pointed by the references inside the stack lives in the heap.</p>
  
  <p>But when it comes to method local non primitive object initialization, wouldn't that cause a concurrency issue ? I mean if the method locals non primitives lives in the heap and only the pointers lives in the stacks, isn't it the same as of instance variables ? </p>
  
  <p>Can someone please help me to understand this.... </p>
  
  <p>PS </p>
  
  <p>Think of two threads with each having two stacks of their own and one heap. What I understood is that the two threads keep their method local primitive variables inside their stacks. I have no issue with that. </p>
  
  <p>But what if we have a method with non primitive method local variables ? Then if the object for that variable is stored inside the heap, both the threads will have the access to the same object, won't they ? So if that's the case there would be Sync problems. </p>
  
  <p>That is what I'm asking.</p>
  
  <p>Thanks  </p>