Make random-state initialization threadsafe