I want to know if creating a new thread in Java triggers a cache flash. Suppose I do something similar in this sequence:
- The thread starts and sets the variable X.
- A stream is created in the stream.
- The new thread accesses X.
My question is this: is this a new thread, either at the time of its creation or at the time of its launch, guaranteed to view the update made by X on the old thread in step 1? I understand that if the old thread changes the value of X in the future, it will not guarantee that the new thread will see these changes. It's great. I just want to know if the new thread will see the correct values when it starts without the need for explicit synchronization.
When I first decided to study this topic, I thought that a simple Google search would immediately open the answer, but for some reason I can’t find a result that solves this issue.
source share