I have seen the below question.The answer was to use the semaphores instead.This didnot answer one of the other problems stated in the question which I am facing.
I have a parent thread which sets some unique identifier for each new request in an InhertiedThreadLocal and submits 2 Runnable Tasks to the ThreadPool i.e for 2 threads. For the initial request the values that are set for InheritedThreadLocal in the parent thread are propagated to the ChildThread correctly. For the next requests,the childthreads are not receiving the latest InheritedThreadLocal set by the parent Thread and the old values in the ChildThread are used.
This is because threadpool reuses threads and the InheritedThreadLocal are copied only when new thread is created.
Now how can I propagate the latest value of InheritedThreadLocal from parent to Child thread in the thread pool scenario. Is there a way out for this ?
If we configure ThreadPoolExecutor like this
it will create a new Thread each time thus InheritableThreadLocals will be inherited, though then it can hardly be called a ThreadPoolExecutor