import java.util.Random; import java.util.concurrent.*; import java.util.Vector; public class Main { static class TimeConsumingTask implements Runnable { public Vector results = new Vector<>(); @Override public void run() { System.out.println("Task thread: " + Thread.currentThread().getName()); System.out.println("Running time consuming task: " + System.currentTimeMillis()); try { doSomething(0); } catch(Exception e) { System.out.println("[Thread " + Thread.currentThread().getName() + "] Exception caught. Printing stack trace ..."); e.printStackTrace(); System.out.println("[Thread " + Thread.currentThread().getName() + "] Exit."); return; } } private int doSomething(int depth) throws Exception { final long total_ints = 1<<20; if(depth == 5) { long numbers_to_gen = total_ints / (1<