Add mutex to synchronize result array updating.