classpath
[Top][All Lists]
Advanced

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

RE: StringBuilder


From: Jeroen Frijters
Subject: RE: StringBuilder
Date: Fri, 17 Dec 2004 15:09:30 +0100

Thomas Zander wrote:
> Interresting concept;
> several bugs:
> 1) doing an aquire can return a null;  meaning the toString() 
> can cause nullpointer exceptions.

Only if you use it concurrently from different threads. StringBuilder
isn't thread safe so this is perfectly acceptable.

> 2) the release should be synhronized.

No it shouldn't.

> Hmm; there are several other bugs which have to do with threading..

You might want to study the Java memory model before making such claims.

> A better solution would be have the complete implementation 
> of append() and  toString() in a synchronized block on a lock object.

The whole point of StringBuilder is to avoid synchronization.

Regards,
Jeroen




reply via email to

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