volatile stop flag와 join 결과의 서로 다른 publication

field마다 어떤 happens-before edge로 값이 전달되는지 표시한다.

Main write

running=false를 volatile로 쓴다

release

Worker read

loop에서 같은 flag를 읽는다

acquire
worker termination

Worker write

iterations 결과를 일반 field에 둔다

before end

Main read

join 반환 뒤 결과를 본다

visible

핵심: 한 객체 안에서도 stop signal과 completion result는 다른 동기화 경계를 사용할 수 있다.