Both are completely unrelated.
两者是完全没有关系的。
The ThreadLocal class stores a variable in the Thread object of the current running thread, each thread gets its own copy of ThreadLocal instance, the ThreadLocal instances are not shared among the Threads.
ThreadLocal 类在当前正在运行的线程的Thread对象中存储一个变量,每个线程获得它自己的ThreadLocal实例副本,ThreadLocal实例不在线程之间共享。
Volatile keyword instructs the compiler that this variable be accessed/shared across multiple threads.
volatile 指示编译器认为该变量可以跨多个线程访问 / 共享。
原文地址
本文发布于:2024-02-04 23:48:33,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170719173360874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |