Code example for ThreadPoolExecutor

Methods: awaitTermination, shutdown, submit

0
		Task systemTask=new Task(system,null);
		Task appsTask=new Task(apps,null);
		Task documentsTask=new Task(documents,null);
		 
		// Submit the Tasks to the Executor 
		executor.submit(systemTask);
		executor.submit(appsTask);
		executor.submit(documentsTask);
		 
		// Shutdown the executor and wait for the end of the tasks 
		executor.shutdown();
		try { 
			executor.awaitTermination(1, TimeUnit.DAYS);
		} catch (InterruptedException e) {
			e.printStackTrace();
		} 
		 
		// Write to the console the number of results 
		try { 
			System.out.printf("Main: System Task: Number of Results: %d\n",systemTask.get().size());
			System.out.printf("Main: App Task: Number of Results: %d\n",appsTask.get().size());