The difference between String \ StringBuffer \ StringBuilder

1、String

final modification, immutable

String takes more time than the same thread is 25 times the StringBuffer 7500ms

2、StringBuffer 

Final decoration, variable, thread-safe, check the jdk source code can be found that most of the methods are synchronized (synchronous code block) decoration

StringBuffer takes less time

3.StringBuider is 0.5 times the StringBuilder under the same thread 300ms

final decoration, variable, thread unsafe, no synchronized decoration

StringBuilder usage time is at least 250ms

Guess you like

Origin www.cnblogs.com/kwzblog/p/12691385.html