We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,做项目是遇到一个问题:
用线程池去执行一个执行时间较长的任务,但是任务线程需要父线程的ThreadLocal。而TransmittableThreadLocal传递似乎只是传递了引用,并不是深拷贝。
这样会引起一个问题,父线程ThreadLocal如果置空或者值有修改的情况下,任务线程也会随之改变。我觉得在任务提交后,值不应该有变动吧?
请问能否控制拷贝方式呢?
不好意思,第一次提问,请多包涵哈,若能帮忙解惑,不胜感激~
The text was updated successfully, but these errors were encountered:
值传递拷贝方式通过覆写TransmittableThreadLocal的protected copy方法来定制,缺省是直接传的是引用。
TransmittableThreadLocal
protected copy
你可以实现成『浅拷贝』、『深拷贝』或是面向你需求的拷贝方式。
你看看,这个 copy方法 是 你说的问题的解决方法 吗? 😁 @Ronustine
copy
Sorry, something went wrong.
niubi
oldratlee
No branches or pull requests
Hello,做项目是遇到一个问题:
用线程池去执行一个执行时间较长的任务,但是任务线程需要父线程的ThreadLocal。而TransmittableThreadLocal传递似乎只是传递了引用,并不是深拷贝。
这样会引起一个问题,父线程ThreadLocal如果置空或者值有修改的情况下,任务线程也会随之改变。我觉得在任务提交后,值不应该有变动吧?
请问能否控制拷贝方式呢?
不好意思,第一次提问,请多包涵哈,若能帮忙解惑,不胜感激~
The text was updated successfully, but these errors were encountered: