title: Instance variable in Java Spring Bean
body: <p>I'm developing a Java Spring MVC project and i hesitate using instance variable in Java Spring Bean.I want to ask some question about this subject.</p>
  
  <p>I used a instance variable in my Java Spring Bean and its type is String.</p>
  
  <pre><code>private String abc = "hell";
  </code></pre>
  
  <p>As we know , Java Spring default scope is Singleton and they are constructed at the startup time of the project. .It is single instance and my instance variable must be thread-safe.</p>
  
  <p>I used this variable "abc" in the methods of the beans and when they are reached by multiple threads will it damage the consistency of data each thread? </p>
  
  <p>For an example , Thread 1 reach the bean and take the abc variable changed it as "hello".On that time , Thread 1 reference to abc variable point "hell" or "hello"? I'm confused at this topic.</p>
  
  <p>I make the String abc variable to <code>ThreadLocal</code> object to provide each thread holds their own abc variable.But i have read that using <code>ThreadLocal</code> objects occurs memory leakage in the Tomcat.After 7.0 version of Tomcat it is said that it is fixed.</p>
  
  <p>Because each thread holds their own variable, and when their job is finished they return the thread pool which is managed by container.But,returning the pool , ThreadLocal object is not destroyed and they cause memory leakage.</p>
  
  <p>Moreover, String object is immutable so in theorical view does it cause the multi-threaded problem ??</p>
  
  <p>is each thread holds their String variable on its own? For example, Thread 1 triggers and then start the method invocation , and create seperate String variable "abc" and Thread 2 triggers then it creates new String variable "abc" and do they damage "abc" variable each other?</p>
  
  <p>I really wonder this concept of usage and eager to learn the answers.</p>