ExecutorService for Do-While Loop in Java
<p>I am new to concurrency and I was trying to implement executor service concurrency for a do-while loop. But I always run into <code>RejectedExecutionException</code></p>

<p>Here is my sample code:</p>

<pre><code>do {    
    Future&lt;Void&gt; future = executor.submit(new Callable&lt;Void&gt;() {
    @Override        
    public Void call() throws Exception {

        // action
        return null;
    }
    });

    futures.add(future);
    executor.shutdown();

    for (Future&lt;Void&gt; future : futures) {
        try {
            future.get();
        }
        catch (InterruptedException e) {
            throw new IOException(e)
        }          
    } 
}
while (true);
</code></pre>

<p>But this seems incorrect. I think I am calling the shutdown at the wrong place. Can anyone please help me implement <code>Executor Service in a do-while</code> loop correctly. Thanks.</p>