add pthread lock