Default threads in Unity

If I don’t spawn any new threads and simply run the game, what threads are there? Am I immediately thrown into multi threaded environment? For example, Monobehaviour’s update() and OnMouseDown() executing simultaneously in multiple threads? Or Is Unity just single threaded and designing multi-threaded system is left up to us the developers?

There are some extra threads happening, but none that will concern you as a script-writer - the most notable extra threads are physics and audio IIRC.

But all of your scripts are executed on the main thread, in a very well-defined and predictable order.

1 Like

Thank you. Does that mean if I put some long synchronous operation that takes 10 mins inside OnMouseDown() method, the whole game will freeze because other game objects’ update() isn’t being called?

Yes, the game will freeze. Long/slow operations should be done in either coroutines or sent off to their own thread.

1 Like