Re:Java StringBuffer and StringBuilder performance
by DannyB2 on Monday June 13, 2016 @04:20PM
(#11897237)
In most cases you WOULD know that StringBuilder is just fine and no thread contention exists. Most common uses of StringBuilder are where the StringBuilder is a local variable used within a single function to build up a string, and then to give you the actual string that was built up. After that the StringBuilder goes out of scope and the garbage collector will eat it up when it gets hungry. The string that StringBuilder gave you is immutable, therefore no other thread can change its value. (And hence the reason why StringBuilder is useful -- it is like a mutable string.)
[ Parent
| on HN ]
There are no comments on this comment yet.