ReportRequest onlineRequest=new ReportRequest("Online", service);
Thread faceThread=new Thread(faceRequest);
Thread onlineThread=new Thread(onlineRequest);
// Create a ReportSender object and a Thread to execute it
ReportProcessor processor=new ReportProcessor(service);
Thread senderThread=new Thread(processor);
// Start the Threads
System.out.printf("Main: Starting the Threads\n");
faceThread.start();
onlineThread.start();
senderThread.start();
// Wait for the end of the ReportGenerator tasks
try {
System.out.printf("Main: Waiting for the report generators.\n");
faceThread.join();
onlineThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
// Shutdown the executor
System.out.printf("Main: Shuting down the executor.\n");
executor.shutdown();
try {
executor.awaitTermination(1, TimeUnit.DAYS);
} catch (InterruptedException e) {
e.printStackTrace();
}
// End the execution of the ReportSender
processor.setEnd(true);
System.out.printf("Main: Ends\n");
}