Why isn't Random.Range thread safe?

I have a terrain generator which spawns a new thread in order to more efficiently load resources while still allowing the program to run in the main thread. I had tried a coroutine instead, but it was simply too slow and kept holding up my main thread.

The problem is that when calling Random.Range from the thread it complains about it not being the Main Thread. I don’t understand why Random.Range is not thread safe. It really should be.

using UnityEngine;

using System.Collections;
using System.Collections.Generic;

class ThreadRandomTest : MonoBehaviour {
	System.Threading.Thread GenerateThread = null;
	bool GenerateThreadFinished = false;
	bool _Generating = false;
	System.Object TerrainBuildQueueLock = new System.Object();
	public void Generate() {
		int Rand = Random.Range(0, 100);
		lock(TerrainBuildQueueLock) {
			_Generating = false;
	public IEnumerator BeginGenerate() {
		lock(TerrainBuildQueueLock) {
			if(!_Generating) {				
				_Generating = true;
				GenerateThreadFinished = false;
				GenerateThread = new System.Threading.Thread(() => this.Generate());
		yield return null;
	void OnGUI() {
		if (GUI.Button (new Rect(5.0f, 5.0f, 100.0f, 25.0f), "Generate")) {
			StartCoroutine(this.BeginGenerate ());

It used to be thread safe, sometime before Unity 4. Not sure when that stopped exactly, or why. You can use System.Random instead.

When a function like this isn’t thread save, the most likely reason is that there is some global variable that is being set by the function. In this case, Random.Range() may modify a hidden global seed somewhere, and if that seed is overwritten by multiple threads calling this function, the distribution of random numbers may get skewed.

This is purely an educated guess though, based off of the non-thread safe rand in C.