gpt4 book ai didi

java - Thread.join()和同步?

转载 作者:行者123 更新时间:2023-12-03 13:17:07 24 4
gpt4 key购买 nike

在执行线程beeing时,Thread.join()是否与刷新缓存等完全同步?

最佳答案

我想您是在询问是否从线程T1调用T2上的join,在join()之后读取数据的T1中的代码肯定会看到T2编写的更改。如果是这样,那么由于JLS 17.4.4,答案是肯定的:

The final action in a thread T1 synchronizes-with any action in another thread T2 that detects that T1 has terminated.

T2 may accomplish this by calling T1.isAlive() or T1.join().


JLS 17.4.5:

All actions in a thread happen-before any other thread successfully returns from a join() on that thread.

关于java - Thread.join()和同步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37839010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com