Skip to main content

Parallel Word Counter

Challenge on lesson: Checkpoint: Concurrency

Build Solution: - static Map<String, Integer> countWords(List<String> chunks, int threads): - split the chunk list into threads sublists (like parallelSum) - each thread counts words in its chunks into its OWN local HashMap<String, Integer> - after joining all threads, MERGE the maps into one - return the merged map The merge must happen after every join — before that, thread-local maps are confined and safe. threads <= 0 → empty map; empty chunks fine.

Difficulty: intermediate

Back to lesson: Checkpoint: Concurrency