@Test
public void testParallel() {

	ExecutionContext context = newExecutionContext();
	ThreadPool threadPool = new ThreadPool(context);
	
	List<String> itemList = new ArrayList<>();
	int iterations = 10000;
	for(int i=0; i<iterations; i++) {
		itemList.add("Item"+i);
	}
	
	List<String> processedItems = new CopyOnWriteArrayList<>();
	
	AtomicInteger count = new AtomicInteger();
	
	threadPool.consumeWork(itemList.iterator(), new WorkerItemConsumerFactory<String>() {
		@Override
		public Consumer<String> createWorkItemConsumer(WorkerController<String> control) {
			return item -> {
				processedItems.add(item);
				count.incrementAndGet();
			};
		}
	}, 5);
	
	for (String item : itemList) {
		if(!processedItems.contains(item)) {
			fail("The item "+item+" hasn't been processed");
		}
	}
	
	// Ensure that each item has been processed exactly once
	assertEquals(iterations, count.get());
}