title: Spring MVC how to get progress of running async task
body: <p>I would like to start an asynchronous task from within controller  like in following code sniplet from Spring docs. </p>
  
  <pre><code>import org.springframework.core.task.TaskExecutor; 
  
  public class TaskExecutorExample { 
  
    private class MessagePrinterTask implements Runnable { 
  
      private int cn; 
  
      public MessagePrinterTask() { 
  
      } 
  
      public void run() { 
  //dummy code 
  for (int i = 0; i &lt; 10; i++) { 
  cn = i; 
  } 
  } 
  
  } 
  
  private TaskExecutor taskExecutor; 
  
  public TaskExecutorExample(TaskExecutor taskExecutor) { 
      this.taskExecutor = taskExecutor; 
    } 
  
    public void printMessages() { 
  
        taskExecutor.execute(new MessagePrinterTask()); 
  
    } 
  } 
  </code></pre>
  
  <p>afterwards in annother request (in the case that task is running) I need to check the progress of the task. Basicaly get the value of cn. </p>
  
  <p>What would be the best aproach in Spring MVC a how to avoid syncronisation issues. </p>
  
  <p>Thanks </p>
  
  <p>Pepa Procházka</p>