Nice to @Share?
Joshua Bloch
jjb at google.com
Mon Feb 22 13:52:07 PST 2010
Neal,
On Mon, Feb 22, 2010 at 1:31 PM, Neal Gafter <neal at gafter.com> wrote:
> I agree with Josh on most of this.
Twice in a week! Will wonders never cease?
>
> As for the name, "shared" doesn't mean that the variable is shared
> between threads. It means that the variable may be shared between the
> method (or lambda) in which it is declared and any nested lambdas.
>
I understand, but I believe that programmers would be very confused by this,
because of the ambiguity in the possible meaning of shared.
> Re 'In practical terms, it means "this variable must *not* be shared
> (without additional synchronization)."', this doesn't really make much
> sense to me; all variables (whether marked @Shared or not) must not be
> shared between threads (without additional synchronization).
>
Not so. Shared *mutable* state must be synchronized. If it's not shared *or
not mutable*, no synchronization is necessary.
Josh
More information about the lambda-dev
mailing list