Thread Variables
In Java its possible to store thread specific variables. The class ThreadLocal provides this functionality. This class is internally implemented with a map. The keys for this map are generated by an AtomicInteger starting on 0.
InheritableThreadLocal are thread variables that can be tnherit to other threads. The whole map with values are inherit to the child thread. This allows it to give each new thread information about its parent thread, so that the new threads can access it.
In thread pools each thread is reused, so it would be enough to set all thread variables on null every time a thread starts and exits execution.
To achieve this it would be necessary to use the finalize() method. But there is no guarantie that and when the garbage collector will run this method, so this aproach cant be used for the tracer.
Threads can be reused, but Runnables are unique.