-
What do you want to achieve? i wanna know what a thread is
-
What is the issue? i dont know what a thread is
-
What solutions have you tried so far? nothing
im being serious with yall, I still don’t know what a thread is
What do you want to achieve? i wanna know what a thread is
What is the issue? i dont know what a thread is
What solutions have you tried so far? nothing
im being serious with yall, I still don’t know what a thread is
It’s like running a separate script within a script that can be controlled from said script.
It’s basically a way for you to split operations or processes.
Think of it as if you’re doing an assignment (one task), and at the same time playing a game on your phone (another task). Both tasks are happening “at the same time” but they belong to you; like threads within the same process.
So you know how in your scripts, the engine will read and run your code one line at a time? We have ways of making multiple lines be run “at the same time”, like when you connect to a event (RemoteEvent.OnServerEvent, RunService.RenderStepped, Humanoid.HealthChanged, etc
) and when you use task.spawn()
and task.delay()
, or simply have a second script running. But these aren’t actually using other threads.
So what are threads? Well, at the simplest, each thread can only read/run one line of code at a time. The above is done all in a single thread by having it jump around to different spots very fast, but if you have multiple threads, you can have multiple lines of code running at the same time.
In roblox, we accomplish this via Actors, which make every script placed inside of them run in a different thread than the rest of your code (and engine!). This does mean that you can’t do certain things in those scripts without syncing them back up with the main thread (with task.synchronize
and task.desynchronize
).
TLDR, for now imagine other threads as entirely separate computers, you can run your code on them to use their extra power with Actors, but they have to talk with the main computer (thread) to use many parts of the engine.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.