1 + 2 + 3 + ... + n = n * (n + 1) / 2
you better start
thread b from within the synchronization block.
edit:
I think the proof is something like this:
0 + ... + n = n * (n + 1) / 2
n = 0: 0 = 0 * 2 / 2 = 0
suppose 0 + ... + n = n * (n + 1) / 2 is true
prove: 0 + ... + n + 1 = (n + 1) * (n + 2) / 2
0 + ... + n + 1
= {trivial}
0 + ... + + n + n + 1
= {1 + ... + n = n * (n + 1) / 2}
n * (n + 1) / 2 + n + 1
= {x = y * x / y}
n * (n + 1) / 2 + 2 * (n + 1) / 2
= {x / z + y / z = (x + y) / z}
(n * (n + 1) + 2 * (n + 1)) / 2
= {x * z + y * z = (x + y) * z}
((n + 1) * (n + 2)) / 2
= {trivial}
(n + 1) * (n + 2) / 2