Should I use StringBuilder or StringBuffer for webapps?

java, java-6, stringbuffer, stringbuilder, thread-safety

Solution

If you are using a local variable you can safely use `StringBuilder`. Each thread will get its own instance.

Problem

I a writing a webapp in Java 1.6 and running it in tomcat. While I am not doing any explicit threading, I wonder about what is going on behind the scenes with Spring and Tomcat. Would I run into any issues using StringBuilder instead of StringBuffer?

Original source

Related problems