This is a known limitation with lua - you can't run two lua threads (under the same lua_State) in parallel. AFAIK lua allows you to define some locking primitives, but they only serve to lock the current lua_State while lua code is executing, so in effect, only one lua thread is really executing at a time.
Your best bet is to create one lua_State per OS thread and device some kind of communication protocol between different lua states (since two states cannot share tables).
P.S.: Once upon a time I tried to rewrite the lua engine with parallelism in mind, but it was so hopefully slow I won't even dignify it with a link here.
On Thursday, June 11th, 2026 at 3:21 AM, H J <
hjans...@gmail.com> wrote:
> Leveraging fast shared memory access on the same (dual-core) CPU, I want to spawn two threads on each core of the same CPU. Is this possible with luajit? (I've been looking into `effil` but don't see how you can direct the task to a specific core...).-- Henk
>
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
lua-l+un...@googlegroups.com.
> To view this discussion visit
https://groups.google.com/d/msgid/lua-l/CAJrhCY%2BwUejTLNbMf2WKauy2%3D%2B8%2BtVA-Jyoq14ABG96imjYH%2Bw%40mail.gmail.com.