Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Fri, 22 Jul 2011 23:41:11 -0400 From: =?ISO-8859-1?Q?Arne_Vajh=F8j?= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: baseline performance test using java ... References: <1309715588.716395@nntp.aceinnovative.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 31 Message-ID: <4e2a42da$0$309$14726298@news.sunsite.dk> Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 72.192.23.157 X-Trace: news.sunsite.dk DXC=\K2hSikVN1UbD]FUj;YcCZYSB=nbEKnk[@IQ>cfbXVeVJPe3\kP5EUQKBm9cfh9BSTM2;kT<[:>[QERb\jB7:9fT;8fofE@[adQ X-Complaints-To: staff@sunsite.dk Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6444 On 7/3/2011 2:45 PM, Patricia Shanahan wrote: > On 7/3/2011 11:33 AM, Abu Yahya wrote: >> On 7/3/2011 11:23 PM, lbrt chx _ gemale kom wrote: >> >>>>> ~ We have all learned we should avoid String(s) and use >>>>> StringBuffer(s) or better yet StringBuilder(s) but there is >>> ~ >>>> Er, no. Strings are great ... >>> ~ >>> I (obviously) meant to say String(s) if you need to build them >>> andStringBuilder(s) >> > if you are working (most of us by now) on some multiprocessing core >>> ~ >> >> If you need to build them, you'd need a StringBuilder. And if you need >> support for multiple threads AND need to modify them, you'd need a >> StringBuffer. > > Often, the StringBuffer locking is not strong enough to be really > useful. If, for example, a thread needs to append two strings to the > buffer and have them appear consecutively in the resulting string, it > needs synchronization at a higher level. StringBuffer is better than StringBuilder in the case where if >1 threads append N characters to it, then you are happy if you get N characters appended don't care about the order. That is practically never the case. The order of characters is almost always significant. Arne