Search code examples
javathread-safetystringbuilderstringbufferjava-6

Should I use StringBuilder or StringBuffer for webapps?


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?


Solution

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