Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
rlmw
· 11y ago · 0 comments
Because he takes a reference to a char[] in the constructor without copying it. char[]s are mutable so this means that the internal state of his String can be mutated by something else without any synchronisation guarantees.
Comments
[–]
MichaelGG
11y ago
But that's nothing to do with thread saftey - even with a single thread if the char[] changes then stuff blows up right?
[–]
sgustard
11y ago
Correct, and Java's String(char[]) makes a copy of the array for that reason. This article's benchmark gets a boost by avoiding that.