Why this Java program hangs (asynchronous html downloader)? <p>Could you please tell me why this Java program hangs ? It's a simple program to download HTML asynchronously using ExecutorCompletionService. I tried to use <code>executor.shutdown()</code> and <code>completionService.shutdown()</code> but both give <code>no such method</code>. I think the problem is with <code>executor</code> and <code>completionService</code> but can't figure out how to stop them not using their shutdown method. </p> <pre><code>import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.util.concurrent.*; class Main { public static void main(String[] args) throws Exception { Executor executor = Executors.newFixedThreadPool(2); CompletionService&lt;String&gt; completionService = new ExecutorCompletionService&lt;&gt;(executor); completionService.submit(new GetPageTask(new URL("http://xn--80adxoelo.xn--p1ai/")));//slow web site completionService.submit(new GetPageTask(new URL("http://example.com"))); Future&lt;String&gt; future = completionService.take(); System.out.println(future.get()); Future&lt;String&gt; future2 = completionService.take(); System.out.println(future2.get()); } } final class GetPageTask implements Callable&lt;String&gt; { private final URL url; GetPageTask(URL url) { this.url = url; } private String getPage() throws Exception { final BufferedReader reader = new BufferedReader(new InputStreamReader(this.url.openStream())); String str = ""; String line; while ((line = reader.readLine()) != null) { str += line + "\n"; } reader.close(); return str; } @Override public String call() throws Exception { return getPage(); } } </code></pre>