[concurrency-interest] What are the odds of an "early read?"

Marco Villalobos mvillalobos at kineteque.com
Thu Apr 7 02:04:45 EDT 2011


I would say that since you did not specify the use of any lock or
synchronized blocks / methods, then all "happens-before" ordering is
thrown out the window, and this program will not be deterministic in
this multi-threaded scenario.

On Mon, Apr 4, 2011 at 12:47 PM, Christian Vest Hansen
<karmazilla at gmail.com> wrote:
> Hi,
>
> Consider the situation where we have an ordinary field A and a volatile field B.
> Thread 1 writes to A and then to B. Then thread 2 reads B and then A,
> and the write to A is guaranteed to happen-before the read of A
> because it piggy-backed on the ordering guarantees of B.
> However, what if a third thread was doing another write sequence
> similar to that of thread 1, but slightly delayed? Could thread 2 then
> observe the write of thread 1 to B, and the write of thread 3 to A?
>
> --
> Venlig hilsen / Kind regards,
> Christian Vest Hansen.
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>


More information about the Concurrency-interest mailing list