Solved parallel execution issue

The exec() method is rippled out as an independent function so that the
counter i will be passed to it instead of globally shared by all the
exec() child processes.

Signed-off-by: Bo Tang <botang.usa@gmail.com>