~ /phase-2
Phase II · Thread-based parallelism

One array, eight threads.

Phase II moves from processes in C to threads in Java. The program computes the sum of cubes of 1,000,000 integers. It divides the array among worker threads and combines their partial sums, then we measure how runtime changes from 1 to 8 threads.

Java · OpenJDK 25Runnable + join()Apple M2 · 8 cores5 configurations × 12 runs

Headline numbers#

0.649ms
Best average, 8 threads
5.79×
Speedup over 1 thread
−15.5%
Slower at 2 threads than 1
60
Timed runs, 12 per configuration

How the program splits the work#

Build the input#

createArray() fills 1,000,000 integers with random values from 0 to 99, as the brief requires (values below 100).

Time the baseline#

singleSum() computes the sum of cubes on the main thread. This is the 1-thread configuration and the expected result.

Partition and start threads#

parallelSum(data, n) divides the array into n contiguous chunks. The last chunk also takes any remainder. It creates one Summer per chunk and starts a Thread for each.

Join and combine#

The main thread calls join() on each worker, then adds its partial sum to the total.

Verify and report#

Each parallel result is checked against the single-thread answer, and the program prints the time, speedup and % improvement.

Objectives#

Java implementation#

Build and explain a program that computes the sum of cubes of the array elements.

Thread-based parallelism#

Split the array across worker threads and combine their partial results.

Performance measurement#

Measure runtime for the required thread counts: 1, 2, 4, 6 and 8.

Scaling analysis#

Compare execution time, speedup and % improvement against the single-thread baseline.

Correctness#

Check every threaded result against the sequential baseline, so the timings measure correct output.

Explanatory reporting#

Document both the numbers and why the results behaved as they did.

Deliverables#

Plan#

Controlled setup, timing method and repeat policy.

Open →

Results#

Averages, raw runs, graphs and interpretation.

Open →

Report#

Full HTML and PDF report with a code appendix.

Open →

Work log#

Owners, handoffs and completion tracking.

Open →

Outcome#

Phase II delivered a working multithreaded benchmark, measured scaling across five thread configurations, and a clear contrast between overhead-limited cases (2 and 4 threads) and speedup-producing ones (6 and 8 threads). It builds on Phase I by moving from process-based to thread-based parallelism, with a more detailed performance analysis.