C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 04 Mar 2017 11:55 AM |
so,
these for example
object.Changed:connect(function() wait(4) end) object.Transparency = 1 print"hello world"
Is the changed function it's own thread? Because waiting 4 seconds only yields in that function, which I assume is because it is it's own thread. Then again I did not test this code but I assume that's how it works. Trying to understand threads a little bit deeper. Thanks. |
|
|
| Report Abuse |
|
|
|
| 04 Mar 2017 12:02 PM |
Yes, You Are Correct
Thank You
Signed,EvilDonutNoob |
|
|
| Report Abuse |
|
|
|
| 04 Mar 2017 12:03 PM |
Yes, event listeners run similarly to coroutines Each invoke is its own separate thread
|
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 04 Mar 2017 12:29 PM |
| Thanks. Wanted to confirm that. :^) |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 04 Mar 2017 12:31 PM |
It doesn't actually work like that.
Roblox's "thread" system is built on coroutines. Only one "thread" is ever running at a time. |
|
|
| Report Abuse |
|
|
|
| 04 Mar 2017 01:13 PM |
I'm aware that Lua is single-threaded, but coroutines run cooperatively. Coroutines mimic having various threads run at once, and I don't feel the need to explain exactly how coroutines work in Lua each time someone asks about events.
You can feel free to do that though.
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 04 Mar 2017 01:33 PM |
It is necessary that people know that only one thread is running at a time.
Or they may get unexpected results, or write code with the intent of locking thread execution when it isn't needed. |
|
|
| Report Abuse |
|
|
|
| 04 Mar 2017 01:40 PM |
Yeah, you're right. I just get sick of repeating myself here over and over.
|
|
|
| Report Abuse |
|
|