... finding a "unique" thread id of a currently executing Thread
the ruby-way :
Thread.current.object_id
this will work in all rubies however it might not be really "unique" ... see some servers (and puma might do that as well) might re-use "native" threads (e.g. using a fixed thread pool) thus the id might actually be the same for 2 requests executing one after the other.
depending on the implementation details it might be a different ruby Thread
(although it's unlikely) object but under JRuby will be the same Java Thread ... you can get the "native" java.lang.Thread
id using :
JRuby.reference(Thread.current).native_thread.id
in general if you need something truly unique per request basis you should base it on e.g. the (Rack/Rails) Request
object itself which is not reused (recycled) by the application/server.