Re:Java StringBuffer and StringBuilder performance
by veddan on Monday June 13, 2016 @03:48PM
(#11896858)
Unless your program is designed to work that way, the fine-grained synchronization that StringBuffer offers over StringBuilder is almost certainly not very useful. And since Java is a memory-safe language, the only meaningful difference between StringBuffer and StringBuilder in "accidentally" multi-threaded code is the exact manner in which your output will garbled.
[ Parent
| on HN ]
Re:Java StringBuffer and StringBuilder performance
by kbenson on Monday June 13, 2016 @04:17PM
(#11897215)
Up-thread, lmm, said "You wouldn't necessarily know, or notice - your users would just experience occasional random crashes." Are you saying that's incorrect?
If so, that's less an issue of safety, as much as it is data integrity, which is to my mind a less important constraint to keep. In that case, an argument about defaults with respect to safety is a non-sequitur, so I don't really have a point to argue with respect to this example (if true).
Re:Java StringBuffer and StringBuilder performance
by mcguire on Monday June 13, 2016 @09:47PM
(#11899203)
I think your definitions are wrong there. A crash is the best thing that can happen in the case of most, if not all errors. A program that generates bad data, or even worse, converts good data to bad data is much, much worse.