// Update is called once per frame void Update() { if (hasToLoadTerrain) { hasToLoadTerrain = false; // if loadTerrain is called here in the main thread, the scene will // freeze for almost 10 seconds and then all the logs are showed. //loadTerrain(); // on the other hand, if loadTerrain is called inside the threadPool // the scene will not freeze and the logs will be printed meanwhile. threadPool.AddBackgroundAction(loadTerrain); // this thread never stops threadPool.AddBackgroundAction(keepChanginColor); // if keepChanginColor was called directly, the Update function never ends // and the scene freezes } gameObject.transform.eulerAngles = gameObject.transform.eulerAngles + new Vector3(0, 1.0f, 0); }