Do child threads inherit parent ThreadScope in Java?

In Java I have Thread A. If it Aspawns a child thread, bdoes it have baccess to any / all ThreadLocalvariables that have been set A?

+3
source share
2 answers

If you mean InheritableThreadLocal (extension ThreadLocal), then yes, each child thread will have an initial default value so that it is the same as the value of the parent thread. But any changes to the child stream will be local to the child.

InheritableThreadLocal doc

+5
source

, . Thread , , .

+3

All Articles