Move random generation to its own thread.