// Create a list of products
ProductListGenerator generator=new ProductListGenerator();
List<Product> products=generator.generate(10000);
// Craete a task
Task task=new Task(products, 0, products.size(), 0.20);
// Create a ForkJoinPool
ForkJoinPool pool=new ForkJoinPool();
// Execute the Task
pool.execute(task);
// Write information about the pool
do {
System.out.printf("Main: Thread Count: %d\n",pool.getActiveThreadCount());
System.out.printf("Main: Thread Steal: %d\n",pool.getStealCount());
System.out.printf("Main: Paralelism: %d\n",pool.getParallelism());
try {
TimeUnit.MILLISECONDS.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
}
} while (!task.isDone());
// Shutdown the pool
pool.shutdown();
// Check if the task has completed normally
if (task.isCompletedNormally()){
System.out.printf("Main: The process has completed normally.\n");
}
// Expected result: 12. Write products which price is not 12
for (int i=0; i<products.size(); i++){