I need to execute some tasks in parallel, in such a way that the main calling thread will not be blocked. Each task will be terminated if timeout occurs and I will have the ability to cancel all the tasks at once if user changed his mind.

What I came up with is:

The main thread calls new DownloadWatcherThread (so it won't be blocked).
DownloadWatcherThread has run method like this: 

```
public void run() {
    executorService = Executors.newFixedThreadPool(numberOfThreads);
    futures = new ArrayList<Future>();
    for(Component component: components) {

        PackageDownloader downloader = new PackageDownloader(component);
        futures.add(executorService.submit(downloader));
    }

    for(Future future: futures){
        try {
            future.get(8, TimeUnit.HOURS);
        } catch(Exception e) {
            future.cancel(true);
        }
    }

    executorService.shutdown();
}

public void cancelTasks(){      
    executorService.shutdownNow();
}

```

So, the question is this the correct way to achieve all the 3 ingredients?

1. Not blocking the calling thread
2. Timeout task if it takes long time
3. Cancelling the whole thing if the user wishes so