classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cp-patches] StringBuilder and Appendable for CVS HEAD


From: Jeroen Frijters
Subject: RE: [cp-patches] StringBuilder and Appendable for CVS HEAD
Date: Thu, 16 Dec 2004 20:37:16 +0100

address@hidden wrote:
> >>>>> "Jeroen" == Jeroen Frijters <address@hidden> writes:
> 
> Jeroen> In the String(StringBuilder) constructor:
> Jeroen> +            buffer.shared = true;
> Jeroen> +            value = buffer.value;
> 
> I thought the synchronized block in this method would force a commit
> of "shared".  I'm not an expert on the memory model though.

It forces a commit on the writing thread, but the reading thread can
still continue to use its locally cached value (until it enters a
synchronized block, or does a volatile read).

> Anyway, I'd prefer we find a way to make it possible not to reallocate
> the characters when constructing the String.  It seems to me that
> sharing is optimizing for the common case.

I'd prefer it too, but it simply isn't possible (without
synchronization).

Regards,
Jeroen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]