ThreadLocal value access across different threads

前端 未结 5 1074
南笙
南笙 2020-12-09 19:29

Given that a ThreadLocal variable holds different values for different threads, is it possible to access the value of one ThreadLocal variable from another thread?

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 20:19

    It only possible if you place the same value in a field which is not ThreadLocal and access that instead. A ThreadLocal by definition is only local to that thread.

提交回复
热议问题