title: Why it's not possible to get the Runnable embedded in a Thread?
body: <p>As far as I can understand from the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" rel="nofollow noreferrer"><code>java.lang.Thread</code></a> docs, and from other questions posted here on stackoverflow, like "<a href="https://stackoverflow.com/questions/2300579/how-to-access-a-runnable-object-by-thread">How to access a Runnable object by Thread?</a>" and "<a href="https://stackoverflow.com/questions/8021809/get-current-instance-of-runnable">Get current instance of Runnable</a>" it's not possible to get a reference of the <code>Runnable</code> object embedded in a <code>Thread</code>.</p>
  
  <p>A scenario where having this possibility would be useful is when implementing a method, whose signature can't be modified because we are overriding a method defined in another class or interface, and different operations are required to be performed depending on the type of <code>Runnable</code> embedded in the current <code>Thread</code>.</p>
  
  <p>If we had for example a method called <code>getRunnable</code> in the <code>Thread</code> class we could do something like this:</p>
  
  <pre><code>if (Thread.currentThread().getRunnable() instanceof Type1) {
    // do something...
  } else {
    // do something else...
  }
  </code></pre>
  
  <p>This could be useful also in situations when we want to ensure the operations contained in a method are executed only by certain threads and not by others.</p>
  
  <p>So I was wondering, is there a specific reason why the Java developers decided to not allow to get the <code>Runnable</code> instance from a <code>Thread</code>, or is it be a missing feature worth to be notified? If you think there is no reason behind that choice but it's not worth to notify it as missing feature, what strategy would you use in the scenario described above?</p>