user2676185
user2676185

Reputation: 7

Variable visibility when thread terminates

Could somebody please tell me whether or not the visibility of member variables is guaranteed when a worker thead returns and terminates normally; is a volatile write/read sequence still required in order to guarantee visibility?

Upvotes: 0

Views: 48

Answers (1)

ZhongYu
ZhongYu

Reputation: 19682

After thread t2 detects that thread t1 has terminated, through t1.isAlive() or t1.join(), any writes in t1 is visible to t2. See http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4.4

Upvotes: 1

Related Questions