Yes.

It could be that he sees Point(x=3, y=0) or Point(x=0,y=4) or new
Point(x=0,y=0).

And if the x and y where double or long, you could even have values 'out of
thin air' because a read/write on these fields isn't not 'atomic'. So it
could be that the write is done in 2 steps and interleaved with a read that
also is done in two steps.

But I'm not an expert.. I needed to fresh up my knowledge as well.

It is much easier to reason about correctly synchronised programs than about
not correctly synchronized programs.

On Mon, Sep 13, 2010 at 5:00 PM, John Cowan <[email protected]> wrote:

> On Mon, Sep 13, 2010 at 10:48 AM, Peter Veentjer <[email protected]>
> wrote:
>
> > But as soon as one of the fields is not final, you could see freaky stuff
> > since the
> > publication of the object can happen before the completion of the
> > constructor and
> > impossible state could be observed by other threads.
>
> Are you saying that when I say "SomeClass.point = new
> java.awt.Point(3,4)"  another thread might see a value of
> SomeClass.point that is a Point but with the wrong values?
>
> Yeeks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "JVM Languages" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<jvm-languages%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jvm-languages?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to