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 21:25:30 +0100

address@hidden wrote:
> >>>>> "Jeroen" == Jeroen Frijters <address@hidden> writes:
> 
> >> 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.
> 
> Jeroen> I'd prefer it too, but it simply isn't possible (without
> Jeroen> synchronization).
> 
> What if we mark the "shared" field volatile?

Doesn't help. If StringBuilder is busy modifying the character array in
one thread (after it checked the shared flag) and on another thread a
new String is constructed from that StringBuilder object, you now have a
mutable String.

> It would be exceedingly lame if this class, whose motivation must just
> be improved performance, simply represents a tradeoff of
> synchronization versus GC.

There are ways to make it work, but non of them are suitable for
Classpath. Individual VMs should probably special case this class if
they feel it worthwhile.

Regards,
Jeroen




reply via email to

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