Appending to a list in parallel works:
b = {};
SetSharedVariable[b]
WaitAll[Table[ParallelSubmit[{p}, AppendTo[b, 1]], {p, 3}]];
(* b is now {1,1,1} *)
But stuffing a Bag
in parallel doesn't:
b = Internal`Bag[];
SetSharedVariable[b]
ParallelDo[Internal`StuffBag[b, 1], {3}]
Internal`BagPart[b, All]
(* b is now {} *)
What am I doing wrong?