Getting the current call stack from a different thread <p>In a multiple thread situation, is it possible to get the call stack at the current moment inside some thread <code>t1</code> from another thread <code>t2</code> running outside of <code>t1</code>? If so, how?</p> <p><hr></p> <h3>Response to Stefan:</h3> <p>I tried:</p> <pre><code>def a; b end def b; c end def c; d end def d; sleep(1) end t1 = Thread.new do 100.times{a} end p t1.backtrace </code></pre> <p>but it always returns an empty array <code>[]</code>.</p> <p><hr></p> <h3>Edit:</h3> <p>Following suggestions by Stefan, the following parameters worked for my computer:</p> <pre><code>def a; b end def b; c end def c; d end def d; end t1 = Thread.new do 1000.times{a} end sleep(0.0001) p t1.backtrace </code></pre> <p>It returns a random call stack with the top-most method varying around <code>a</code> to <code>d</code>.</p>