title: How does Spring MVC handle multiple users
body: <p>I am using spring from more than 6 months. I am not able to understand this underlying mechanism related to the below scenario.</p>
  
  <p>I have a spring web app. Now I autowired the model in controller. Based on url matching it calls respective method. all my methods are singleton. </p>
  
  <p>Now when two users are opening app at same time spring is able to run them parallelly and give results to them. I didnt understand how can it do this. i mean as the bean is singleton it has to either the wait till the bean is not used or overwrite the data in the bean. But spring is working correctly. Can someone explain this behaviour with some analogy.</p>
  
  <p>To explain my question clearly below is a piece of code:</p>
  
  <p>My default controller is simple one:</p>
  
  <pre><code>@Autowired  
  private AppModel aModel; 
  public AppModel getModel(){
      return aModel;
  }
  public void setModel(AppModel aModel){
      this.aModel = aModel;
  }
  
  @RequestMapping(method = RequestMethod.GET)
  public ModelAndView defaultGetter(HttpServletRequest request,
          HttpServletResponse response) throws Exception {
      ModelAndView mav = new ModelAndView(getViewName());
      mav.addObject("model", aModel);
      Runtime.getRuntime().gc();
      return mav;
  }
  </code></pre>
  
  <p>Also can some one tell me when two clients open the app will two seperate models get generated when i use @autowired . If only one model bean exists for all clients then say the request from client 1 came in and it take me 30 sec to get results back. Now if second client sends request in 3rd sec then will the first clients request gets overwritten?</p>
  
  <p>I think I am getting confused. Can some one clarify how this magic is happening?</p>
  
  <p>Thanks</p>