Add Philippes thread safety fix v5-34-22

These should fix additional thread safety problem found by running helgrind on CMS' reconstruction job.