Friday 15 July 2011

java - Reading from a field in multithreading -



java - Reading from a field in multithreading -

as far understand thread may create thread_local cache of variables one's going read. also, volatile field means thread reads variable one's actual value , doesn't depends on value cached within thread. so, should declare field volatile time we're going read 1 threads?

volatile used indicate variable's value modified different threads. yes should declare fellow member volatile if plan read other thread.

access volatile variable acts if enclosed in synchronized block. don't need explicit synchronization.

java multithreading volatile

No comments:

Post a Comment