Code example for ThreadPoolExecutor

Methods: execute, getActiveCount, getCompletedTaskCount, getPoolSize

0
	/* 
	 * implements the execute task method 
	 */ 
	public void execute(Task task) {
		System.out.printf("Server: A new task has arrived\n");
		executor.execute(task);
		System.out.printf("Server: Pool Size: %d\n", executor.getPoolSize());
		System.out.printf("Server: Active Count: %d\n",
				executor.getActiveCount());
		System.out.printf("Server: Completed Tasks: %d\n",
				executor.getCompletedTaskCount());
 
	} 
 
	 
	/* 
	 * to end up executor 
	 */ 
	public void endServer() { 
		executor.shutdown();
	}