title: Spring Autowiring and thread-safety
body: <p>I am new to Spring and recently created a test RESTful web service application.
  I am following the Spring <code>@Autowiring</code> way of injecting the beans. Below is my code and a question:</p>
  
  <pre><code>@Service
  public class HelloWorld {       
  
      @Autowired
      private HelloWorldDaoImpl helloWorldDao;
  
      public void serviceRequest() {
          helloWorldDao.testDbConnection();
      }
  
  }
  
  @RestController
  public class HelloWorldController {
  
      @Autowired
      private HelloWorld helloWorld;
  
      @RequestMapping(value = "/test", method = RequestMethod.POST)
      public String test() {
          helloWorld.serviceRequest();
          return "Success";
      }
  }
  </code></pre>
  
  <p>Now my question is, when I have two requests coming in exactly at same time and they both are sharing the same Service class variable "helloWorld", then how do we ensure that value returned for Request 1 does not go to Request 2 and vice-versa?</p>
  
  <p>Does Spring take care of such multi-threading issues automatically when we use <code>@Autowired</code>?</p>