I have 2 threads each with a Threadlocal list named threadLocal that will both spawn child threads. I want the child threads to be able to modify the parent's threadLocal.
I have tried passing in the parent itself to the child so that it can call parent.threadLocal.get().add(x) but this causes a null pointer exception. When the parent calls threadLocal.get().add(x) it is able to add x to the list just fine.
I know the issue is with the .add(x) because having the child just call .get() does not cause an exception. I also tried passing the threadLocal itself to the child and that gives the same error.
Is there a way to do this?