title: execute a ruby thread in a specific context
body: <p>In the spirit of <code>instance_exec</code> with blocks, is there a way to do something similar for a thread? Instead of:</p>
  
  <pre><code>def context_thread_for(object, *args, &amp;block)
    Thread.new do
      object.instance_exec(*args, &amp;block)
    end
  end
  
  context_thread_for(custom_dsl_object) { dsl_method }
  </code></pre>
  
  <p>Is there a way to pass the context right to the thread without wrapping it? </p>
  
  <p>Trying to benchmark different approaches because I read somewhere <code>instance_exec</code> is slow, but I can't figure out how to do it. Maybe with a <code>binding</code>?</p>
  
  <p><strong>edit</strong></p>
  
  <p>Dennis, I'd wanna use it for this: <a href="https://github.com/aj0strow/async_enum#preventing-race-conditions" rel="nofollow">https://github.com/aj0strow/async_enum#preventing-race-conditions</a></p>