Should I use StringBuilder or StringBuffer for webapps?

I am writing webapp in Java 1.6 and running it in tomcat. Although I don't make any explicit threads, I wonder what happens behind the scenes with Spring and Tomcat. Will I encounter any problems using StringBuilder instead of StringBuffer?

+5
source share
5 answers

If you use a local variable, you can safely use StringBuilder. Each thread will receive its own instance.

+10
source

Java EE , , , StringBuilder, . , , StringBuffer.

, , StringBuilder , .

+1

(doGet/doPost), . Spring bean, , bean .

0

StringBuilder, doPost doGet . , , , , ! , , . , .

0

Java java.lang.StringBuffer:

, (, ) , , .

This means that your operations with your StringBuffer will be safe, even if you are in a multi-threaded environment [for example, in a web application]. The security of your StringBuffer instance as such is determined by the scope of the variable.

0
source

All Articles