commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject [lang] StringUtils thread safety
Date Sat, 26 Jul 2003 15:44:43 GMT
I have changed the padding() method in StringUtils.

The original version was definitely thread-unsafe, as two threads could have
competed to update the static at the same time.

The new version is PROBABLY thread safe. It doesn't synchronize, but does
rely on atomic read and write into an array element. Now I know read/write
of a simple object IS atomic, but I don't know about an array element.

// assumed to be atomic read:
String pad = PADDING[ch];
// assumed to be atomic write:
PADDING[ch] = pad;

So, any thread expects out there???

Stephen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message