public static void main(String[] args) {
	ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
	List<Future<Integer>> results = new ArrayList<>();
	for (int i = 0; i < 5; i++) {
	    Future<Integer> submit =
		    newCachedThreadPool.submit(new MyCallable(5 + i));
	    results.add(submit);
	}

	for (Iterator<Future<Integer>> iterator = results.iterator(); iterator
		.hasNext();) {
	    try {
		Future<Integer> future = iterator.next();
		Integer result = future.get(1, TimeUnit.SECONDS);
		System.out.format("\nThe result of %s is %s\n", future, result);
	    } catch (InterruptedException e) {
		e.printStackTrace();
	    } catch (ExecutionException e) {
		e.printStackTrace();
	    } catch (TimeoutException e) {
		e.printStackTrace();
	    }

	}
    }