generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Understanding threads

Previous Thread :: Next Thread 
C_Sharper is online. 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
EvilDonutNoob is not online. EvilDonutNoob
Joined: 26 Jan 2014
Total Posts: 440
04 Mar 2017 12:02 PM
Yes, You Are Correct

Thank You

Signed,EvilDonutNoob
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
04 Mar 2017 12:03 PM
Yes, event listeners run similarly to coroutines
Each invoke is its own separate thread


Report Abuse
C_Sharper is online. C_Sharper
Joined: 03 Oct 2011
Total Posts: 6405
04 Mar 2017 12:29 PM
Thanks. Wanted to confirm that. :^)
Report Abuse
chimmihc is not online. 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
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
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 is not online. 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
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
04 Mar 2017 01:40 PM
Yeah, you're right. I just get sick of repeating myself here over and over.


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image