Comments (3)
这样假如此时 另外一个线程池中的线程 调用了
copy()
方法
holder.get()
是ThreadLocal
的(holder
本身是ThreadLocal
),只属于当前线程。
# ThreadLocal#get()
只能 拿到 当前线程 的数据。
即这个数据不会被另一个线程访问使用的,没有并发问题。
更具体 可以再看看一下ThreadLocal
的使用与限制。
// 没太理解此处,为何将copied中不存在,holder中存在的 threadlocal remove?
// clear the TTL value only in copied
// avoid extra TTL value in copied, when run task.
if (!copied.containsKey(threadLocal)) {
iterator.remove();
threadLocal.superRemove();
}
上面的代码注释 说明了。
如果不这么做这个删除,那么 TTL
这些值 就比 copied
里多出来了,
不没有正确 恢复/回放值。
比如 原来的copy
过来的值是 a=1,b=2
,回放运行的线程原来就有值z=100
。
不做这个删除,回放运行时,就有值a=1,b=2,z=100
,不预期了。
可以自己写段代码运行Debug一下就好了,或者 自己理解一下TTL
的执行过程,这个就很容易理解了。
PS
这个Issue也提交错了 仓库,@tianjialin 请 提交到 ❤️
https://github.com/alibaba/transmittable-thread-local/issues
from translations.
仔细有想了想 ThreadLocal 的运行原理,理解了,非常感谢百忙之中回复。
另:
我是单击 TransmittableThreadLocal 仓库下README里 “建议和提问,提交Issue” 进来的,我还以为提问都是在这提问。操作有误,实在抱歉
from translations.
麻烦 提到ttl中,方便大家也看到了解,谢谢
我是单击 TransmittableThreadLocal 仓库下README里 “建议和提问,提交Issue” 进来的,我还以为提问都是在这提问。
README 有误,给个pr fix一下? 💕
from translations.
Related Issues (20)
- - HOT 3
- 译:CodeHaus Manifesto
- 译: A Look Into NASA’s Coding Philosophy
- 译: How Optional Breaks the Monad Laws and Why It Matters
- 整理译文: 分布式快照(Chandy-Lamport算法)
- 翻译: A practical introduction to functional programming HOT 1
- oldratlee域名已经被回收了 HOT 1
- 随机的int有问题 HOT 2
- overlapping-experiment-infrastructure-more-better-faster-experimentation 一处错误 HOT 1
- 翻译论文:Matching Objects with Patterns
- a-java-fork-join-framework 译文的一点疑问 HOT 3
- translate "Improving the Beginner’s PID – Introduction" HOT 1
- translate "State of Loom"
- translate clojure/FP articles of Uncle Bob HOT 1
- 1 HOT 10
- 翻译:The Art of Control Engineering: Science Meets Industrial Reality
- Fork/Join Typo HOT 2
- 关于Gitflow工作流中,维护分支和开发分支合并的疑问
- 翻译 TechnicalDebtQuadrant
- Java Fork/Join框架 2.1 一处笔误
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from translations.