What is a Thread?

I hear a lot about this in the topic of micro-optimization/benchmarking. But what exactly is a thread? A place where code is ran? A script? A scope? A function? I am not really sure to be honest and I can’t find anything online which has made me to think maybe lua just doesnt have any threads. Then again what do I know…

Essentially a thread is some sequence of operations to be performed. Programs are often split into multiple threads based on the task as hand or, and as you mentioned, for optimization. Lua does in fact have threads. The simplest way to create a new thread is by using the spawn() function.
Here’s an article from the Roblox Developer Wiki:
Threading Code (roblox.com)
And here’s another from Wikipedia about threads more generally:
Thread (computing) - Wikipedia

1 Like