title: Multi Threaded Application with (Spring) ThreadPoolTaskExecutor
body: <p>I need to implement Multi Threaded background process.  My project is spring , hibernate based I tried with below code which uses org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor to perform the 
  below background operation in multi threaded manner.</p>
  
  <p>I need to know </p>
  
  <ol>
  <li>If I use Spring ThreadPoolTaskExecutor is this multi threaded?</li>
  <li>Will there be overlapping issues like multiple threads acqure the same user object ?</li>
  <li><p>If "YES" Should I need to use synchronize the method upgradeUserInBackground() to avoid 
  such a situations ? Alternative solution ?</p>
  
  <pre><code>public class UserUpdateProcessor implements InitializingBean {
  private ThreadPoolTaskExecutor executor;
  public void afterPropertiesSet() throws Exception {            
      executor.execute(new UserBackgorundRunner ());
  }
  }
  
  private class UserBackgorundRunner extends Thread {
  
  public UserBackgorundRunner() {
      this.setDaemon(true);
      this.setPriority(MIN_PRIORITY);
  }
  </code></pre>
  
  <p>public void run() {</p>
  
  <pre><code>    List&lt;User&gt; users = getUserList();;
  
      for (User user : users) {
          try {
              upgradeUserInBackground(user);
          } catch (Exception e) {
              LOGGER.warn("Fail to upgrade user");
          }
      }
  
  }
  </code></pre></li>
  </ol>