By: S. Rao (sonny.delete@this.burdell.org), October 24, 2006 12:40 pm
Room: Moderated Discussions
Gabriele Svelto (gabriele.svelto@gmail.com) on 10/24/06 wrote:
---------------------------
>S. Rao (sonny@burdell.org) on 10/23/06 wrote:
>---------------------------
>>Thinking about it more, since Java constructors are all
>>chained, we would end up with several barriers for
>>every object creation...
>
>Why? Unless all constructors have already been called the object is still considered
>uninitialized and thus shouldn't be visible to other threads.
I guess I was assuming that there was a naive implementation
that put an explicit barrier at the end of every constructor.
Since you could have unknown child classes you wouldn't know
if there needed to be a barrier at the end of a particular
constructor or not (unless it was a final class)
but maybe that's a bit oversimplified and you could say that
the compiler would simply have to emit one after each
explicit constructor call to be safe.
---------------------------
>S. Rao (sonny@burdell.org) on 10/23/06 wrote:
>---------------------------
>>Thinking about it more, since Java constructors are all
>>chained, we would end up with several barriers for
>>every object creation...
>
>Why? Unless all constructors have already been called the object is still considered
>uninitialized and thus shouldn't be visible to other threads.
I guess I was assuming that there was a naive implementation
that put an explicit barrier at the end of every constructor.
Since you could have unknown child classes you wouldn't know
if there needed to be a barrier at the end of a particular
constructor or not (unless it was a final class)
but maybe that's a bit oversimplified and you could say that
the compiler would simply have to emit one after each
explicit constructor call to be safe.