add lock to protect multi-thread MPI calls