I'm using with Log4J2 and ThreadContext and basically, I want the ThreadContext shared across all threads (or an alternative to ThreadContext, as the name seems to imply it should be thread-specific).
Right now I have both of these flags set in my programs arguments (added both, although I think the 2nd legacy):
-Dlog4j2.isThreadContextMapInheritable=true
-DisThreadContextMapInheritable=true
If, when my application first starts up, I do:
ThreadContext.put("key", "value");
The logs both in my parent thread and child thread will both output "value", so I am assuming the ThreadContext is successfully shared between the threads.
However, if I update that message just before my child runs with:
ThreadContext.put("key", "anotherValue");
My child thread still has the original "value", but the next message on the parent thread will be "anotherValue".
Same thing happens if I update the value in my child thread. The child thread will output "anotherValue" but the parent thread will still output "value".
I'm assuming I am missing something crucial about how the ThreadContext works, as what is happening makes no sense to me.