Enhanced paralel_foreach implementation