Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As stated in the <a href="http://download.oracle.com/javase/7/docs/api/index.html?java/util/concurrent/ExecutorService.html">documentation</a>, you cannot reuse an <code>ExecutorService</code> that has been shut down. I'd recommend against any <em>workarounds</em>, since (a) they may not work as expected in all situations; and (b) you can achieve what you want using standard classes.</p> <p>You must either</p> <ol> <li><p>instantiate a new <code>ExecutorService</code>; or</p></li> <li><p>not terminate the <code>ExecutorService</code>.</p></li> </ol> <p>The first solution is easily implemented, so I won't detail it.</p> <p>For the second, since you want to execute an action once all the submitted tasks have finished, you might take a look at <a href="http://download.oracle.com/javase/7/docs/api/index.html?java/util/concurrent/ExecutorCompletionService.html"><code>ExecutorCompletionService</code></a> and use it instead. It wraps an <code>ExecutorService</code> which will do the thread management, but the runnables will get wrapped into something that will tell the <code>ExecutorCompletionService</code> when they have finished, so it can report back to you:</p> <pre><code>ExecutorService executor = ...; ExecutorCompletionService ecs = new ExecutorCompletionService(executor); for (int i = 0; i &lt; totalTasks; i++) { ... ecs.submit(...); ... } for (int i = 0; i &lt; totalTasks; i++) { ecs.take(); } </code></pre> <p>The method <code>take()</code> on the <code>ExecutorCompletionService</code> class will block until a task has finished (either normally or abruptly). It will return a <code>Future</code>, so you can check the results if you wish.</p> <p>I hope this can help you, since I didn't completely understand your problem.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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