I have a strange behavior I cannot explain.
Please have a look at this minimal example:
public class ParallelStreamProgressMonitor
{
public static void main(String[] args)
{
List<Integer> belege = IntStream.range(1, 100).boxed().collect(Collectors.toList());
final ProgressMonitor pm = new ProgressMonitor(null, "Initialmessage", "Initial Note", 0, belege.size());
pm.setMillisToDecideToPopup(0);
pm.setMillisToPopup(0);
pm.setMaximum(belege.size());
pm.setNote("Now I am working");
AtomicInteger counter = new AtomicInteger();
belege.stream().parallel().forEach(b ->
{
System.out.println(b);
pm.setProgress(counter.getAndIncrement());
try
{
//something time consuming ...
Thread.sleep(1000);
}
catch (InterruptedException e)
{
// ignore
}
});
}
}
When executing this, you'd normally expect that a ProgressMonitor will come up and show the progress of the execution.
But this is how it really looks like:
It seems that for every parallel stream executions there is one ProgressMonitor instance extra showing up.
Is there a reason for this? How can I achieve that only one dialog shows up and shows the progress?