# A problem with nested tables and parallelization

My code contains the structure

Table[....,Table[....,{m1,1,N}],{m2,1,M}]


and I would like to use ParallelTable to improve timing. Empirically, I know that ParallelTable[...ParallelTable[...,{}],{}] does not work, so I use

ParallelTable[....,Table[....,{m1,1,N}],{m2,1,M}]


However, these two codes give different results and I do not know why.

i = 1;
Table[i++, {j, 1, 4}]


{1, 2, 3, 4}

h = 1;
ParallelTable[h++, {j, 1, 4}]


{1, 1, 1, 1}

• SetSharedVariable[h], thx – Artem Alexandrov May 12 '20 at 9:54