Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to assign task name in Spring TaskExecutor and check if it is still alive?
    primarykey
    data
    text
    <p>Lest's consider that I have the following:</p> <pre><code>public class MyRunnable implements Runnable { public void run() { //do something expensive } } public class ThreadExecutor { private TaskExecutor taskExecutor; public ThreadExecutor(TaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; } public void fireThread(){ taskExecutor.execute(new MyRunnable()); } } </code></pre> <p>my xml is the following:</p> <pre><code>&lt;bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"&gt; &lt;property name="corePoolSize" value="5" /&gt; &lt;property name="maxPoolSize" value="10" /&gt; &lt;property name="queueCapacity" value="25" /&gt; &lt;/bean&gt; &lt;bean id="threadExecutor" class="com.vanilla.threads.controllers.ThreadExecutor"&gt; &lt;constructor-arg ref="taskExecutor" /&gt; &lt;/bean&gt; </code></pre> <p>in my Spring MVC controller I start the task:</p> <pre><code>@RequestMapping(value="/startTask.html", method=RequestMethod.GET) public ModelAndView indexView(){ ModelAndView mv = new ModelAndView("index"); threadExecutor.fireThread(); return mv; } </code></pre> <p>Now let's consider that I would like to create another request(<code>@RequestMapping(value="/checkStatus.html"</code>) which will tell if the the task started in my previous Request has been finished.</p> <p>So my questions are simple:</p> <p>1) Can I assign name to the task in TaskExecutor and if yes, how can I do it?</p> <p>2) How can I check that the task with that specific name has been done?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload