Practice ยท 2 of 3
Deterministic Parallel Sum
Implement static long parallelSum(int[] data, int parts):
- split the array into parts contiguous chunks (distribute remainder
to earlier chunks)
- compute each chunk's sum on its own thread (plain Thread + join()
is fine)
- combine and return the total
After joining, the combine step is deterministic โ that happens-before
edge is the exercise. Empty array or parts <= 0 โ 0.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Concurrency Lab