this_thread
local this_thread = require 'this_thread'
print(this_thread.get_id())
On some Linux systems, it’s unreliable to get the thread ID from C++-created
threads using pthread_self()
. So if you’re debugging your Lua application and
planning to use FFI to call pthread_self()
you’re bound to find trouble. You
can instead use this module to get the current thread-id by interfacing with the
C++ runtime directly.