Previous inter-Thread tracing approaches
From Braindump in IS advanced:
- Each thread has a unique number (per JVM) automatically assigned
- But threads can and - in fact are - reused. For example thread pools do not instantiate new threads, but instead pass different Runnable instances to the existing threads. Each different runnable is itself a different functionality. Thus the thread ID cannot be safely used for identification
- To build up an invocation sequence, each invoked method must know the method that was invoked before it
- Innerthread communication can simply make use of the ThreadLocal pattern and build a stack of the concrete methods being called
- Interthread and inter JVM communication has to connect the stacks of the involved threads. This can be done by an invocation identifier that is passed from the caller to the callee.
- Invocation identifier must also include the method identification that invoked this call
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.
...
First see Inter-Thread in IS advanced.
To represent the behavior of the application an tree structure of Runnables and their method invocations can be build.
In this tree structure, all trace and context information would be stored.
...