Communication between threads
Communication between threads can be tedious to get right. With a ZeroMQ library, you can easily reuse the previous code to move from the network to interprocess communication merely by changing the transport protocol in the connection string. The LuaZMQ library incorporates simple thread control capabilities but you're free to use any libraries to manage threads.
Note that the Lua language contains coroutines to achieve cooperative multitasking, except that everything is processed in a single thread relying on explicit scheduling. It means that only one CPU core is used by your application.
This recipe will give you basic insight in to parallel processing of information in the Lua language.
You'll be sending the well known filling text Lorem ipsum
to the reply side and it'll append dolor sit amet
in the end. The resulting text will be sent back to the request side and displayed on the screen.
Getting ready
You can view this recipe as a simple mashup of the request...