× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



It's not risky at all. You don't have to synchronize variables that are
inside a method. Synchronization is for globally defined variables that can
change state or methods that change the state of globally defined variables.

Take java.util.List for example. These are used all the time in web
applications and they are not thread safe.

Example Code:

public class SafeStringBuilder {
private SafeStringBuilder() {
}

public static String listToString(List<String> list) {
StringBuilder sb = new StringBuilder();
for (String s : list) {
sb.append(s);
}
return sb.toString();
}
}


I just wrote this up real quick, so I hope there are no typos, but it's
completely thread save. If you invoke the method from several threads, you
will get the expected results. A new thread will not use the same instance
variables.

--
James R. Perkins


On Mon, Apr 27, 2009 at 17:53, Nathan Andelin <nandelin@xxxxxxxxx> wrote:


From: James Perkins
While it's not thread safe, I use it in web applications all the time. As
long as it's a local variable to a method, you're fine.

Is that to say that you use some other form of synchronization for your
methods? If not, that sounds pretty risky to me.

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 thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.