title: Spring injection, global variables
body: <p>Probably my question is wrong and I can't do this way, but I can't find a good explanation.</p>
  
  <p>Here are my classes and my injections with Spring:</p>
  
  <pre><code>public class A
  {
      @Autowired
      protected B b;
  
      public void doSomething(Integer i)
      {
          b.doOtherStuff(i);
      }
  }
  </code></pre>
  
  <p>And here is my B class:</p>
  
  <pre><code>public class B
  {
      private Integer field;
      private List&lt;SomeOtherClass&gt; list = new ArrayList&lt;&gt;();
  
      @Autowired
      protected C c;
  
      public void doOtherStuff(Integer in)
      {
          field = in;
          list = c.getMyList(i);
      }
  }
  </code></pre>
  
  <p>What if I'll have two concurrent calls to a.doSomething(..)? The second call will overwrite the private fields in B and probably the values will not be corret in one of the two executions? Am I wrong?</p>
  
  <p>What if someone calls a.doSomething() and terminates, later B is used (via injection) in another class? Can this last class have an instance of B initialized precedently? </p>
  
  <p>Let me know if my question are unclear, I'm not so good in Java and English too :D</p>