Multi-threading and Corona

Hello!

I am currently building an application that may potentially rely upon URL requests to retrieve data for some of my application’s content. I was wondering if the Corona SDK supports multi-threading?

It would be useful to keep one thread dedicated to the retrieval of web data, and another dedicated to UI responsiveness.

Please let me know what my options are. Thank you! [import]uid: 10211 topic_id: 17274 reply_id: 317274[/import]

Well internally things happen in multiple threads, but Lua, the language behind Corona SDK doesn’t have any explicit thread controls that I’ve seen.

However it is an event driven system and network downloads happen asynchronously in the background while your app moves along doing its thing. A call back function triggers when the network request is complete, interrupting your app to process the response.
[import]uid: 19626 topic_id: 17274 reply_id: 65303[/import]

The closest thing that you can get to threading in Lua, after all the limitations as people call are not with Corona but with Lua.

So, Lua can offer threading with the help of Co-routines. Having said that it is different than having true multi-threading, it is co-operative threading.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17274 reply_id: 65304[/import]

Thank you for your responses.

In that case, is there any sample code I could look at involving co-routines?

Thank you very much! [import]uid: 10211 topic_id: 17274 reply_id: 65305[/import]

Not directly to what you were after, however if you want, you can have a read on co-routines here

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17274 reply_id: 65313[/import]