Ensure thread safety and parallelize by swapping map for pmap.