I am using Rails3 with Puma on JRuby 1.7 with threaded mode ( config.threadsafe!
) enabled.
Now as the theory goes: For multiple client requests which come in, a new thread will be used to serve the user rather than a new rails process being started every time.
If I want to find the id of this new request thread, how can I do so?
for this purpose, you will find following methods useful:
Thread.current
to gets the of thread which is currently being executed
#<Thread:0x8301ef4 run>
Thread.list
to get an array of Thread objects for all threads that are either runnable or stopped.
[
[0] #<Thread:0x8301ef4 run>
]
Hope it helps