[concurrency-interest] Fwd: Synchronization blocks, locks and reorderings

Szabolcs Ferenczi szabolcs.ferenczi at gmail.com
Wed Jan 23 20:40:40 EST 2008


On 24/01/2008, David Holmes <dcholmes at optusnet.com.au> wrote:
>
> > the somewhat more interesting scenario is this:
> >
> > time writer()        reader()
> > ---- --------        --------
> > t1                   lock l
> > t2                   read y
> > t3   write to x
> > t4                   read x
> > t5                   unlock l
> > t6   lock l
> > t7   write to y
> > t8   unlock l
> >
> > Now what value of x will the reader read? According to the
> happens-before
> stuff, value 0 will be > read from x despite that x has actually value 1
> already.
>
> No, the absence of a happens-before ordering between the read of x at t4
> and
> write of x at t3 means that the read can return either 1 or 0


Well, I agree with you and I also said that the code is not correct from the
concurrency point of view. However, you should check it with the author of
http://today.java.net/pub/a/today/2004/04/13/JSR133.html
<http://today.java.net/pub/a/today/2004/04/13/JSR133.html> who
contradicts you.

Best Regards,
Szabolcs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20080124/ee99de79/attachment.html 


More information about the Concurrency-interest mailing list