title: Log4j2 ThreadContext map is not working for parallelStream()
body: <p>I have following sample code:</p>
  
  <pre><code>public class Test {
      static {
          System.setProperty("isThreadContextMapInheritable", "true");
      }
  
      private static final Logger LOGGER = LogManager.getLogger(Test.class);
  
      public static void main(String[] args) {
          ThreadContext.put("UUID", UUID.randomUUID().toString());
          LOGGER.info("in main method start");
          new Test().run();
          LOGGER.info("in main method end");    
      }
  
      private void run() {
          Collections.nCopies(10, 1)
                  .parallelStream()
                  .forEach(i-&gt;LOGGER.info("Inside thread"));    
      }
  }
  </code></pre>
  
  <p>Log4j2 pattern is following:</p>
  
  <pre><code>&lt;pattern&gt;%X{UUID} [%t] %msg %n&lt;/pattern&gt;
  </code></pre>
  
  <p>Running above produce result:</p>
  
  <pre><code>2cf774ff-03c8-483e-9828-451b61349221 [main] in main method start 
  2cf774ff-03c8-483e-9828-451b61349221 [main] Inside thread 
  2cf774ff-03c8-483e-9828-451b61349221 [main] Inside thread 
  2cf774ff-03c8-483e-9828-451b61349221 [main] Inside thread 
  2cf774ff-03c8-483e-9828-451b61349221 [main] Inside thread 
  2cf774ff-03c8-483e-9828-451b61349221 [main] Inside thread 
  2cf774ff-03c8-483e-9828-451b61349221 [ForkJoinPool.commonPool-worker-3] Inside thread 
  2cf774ff-03c8-483e-9828-451b61349221 [ForkJoinPool.commonPool-worker-1] Inside thread 
   [ForkJoinPool.commonPool-worker-1] Inside thread 
   [ForkJoinPool.commonPool-worker-1] Inside thread 
   [ForkJoinPool.commonPool-worker-3] Inside thread 
  2cf774ff-03c8-483e-9828-451b61349221 [main] in main method end 
  </code></pre>
  
  <p>As you can see, the first time in <code>[ForkJoinPool.commonPool-worker-1]</code> and <code>[ForkJoinPool.commonPool-worker-3]</code> threads <code>UUID</code> variable was logged, but other times were not logged.</p>
  
  <p>Why Log4j2 skips <code>ThreadContext</code> variable for some threads and how to fix this?</p>
  
  <p>Thanks for any help!</p>