Make time measurement thread safe.