The problem is that you have a very small array int[] a = new int[] {1, 2, 3, 4, 5, 6}; .
Thread 1 ends before the start of flow.
If you try to run an array of 10,000 or more elements, you can see the difference.
I ran your code with 10,000 elements:
Launching topic number 1.
Launching topic number 2.
The total amount for Thread # 1 is 1
The total amount for Thread # 2 is 1
The total amount for Thread # 1 is 3
The total amount for topic number 2 is 5
The total amount for topic number 2 is 11
The total amount for topic number 2 is 15
The total amount for Thread # 1 is 8
..........
Thus, even if your computer shows threads running sequentially, there is no guarantee that this will be the case on every computer and every time the program starts.
In addition, another error was found in this way:
EDIT
You declared the sum as a field, which should be actually a local variable. You can see in my output how these effects are calculated (the sum from one stream changes by another, etc.).