|
From: James Perkins
It's not risky at all. You don't have to synchronize variables that
are inside a method.
I concede the point to the extent that the SringBuilder object in question
is "new" and "local" to a method, as opposed to a StringBuilder object which
is scoped to the class - an instance variable. I've read several sources
that indicate local variables use "stack" storage as opposed to "heap"
storage, and that every thread has its own stack.
But that raises the question of its applicability. Say a new instance of a
StringBuilder object is created with each method call from each thread in a
Web application. Is the method used a lot? Does it allocate a lot of
memory - appending strings? StringBuilder may perform better than
StringBuffer. But how long before you've left a big trail of garbage to be
collected by the garbage collector? Would it solve one problem and create
another?
Nathan.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.