java-SringBuilder线程不安全-StrngBuffer线程安全,主要就是看看源码上有没有加锁
查看源码可知
StringBuffer
public synchronized StringBuffer append(CharSequence s) {
toStringCache = null;
super.append(s);
return this;
}
StringBuilder
@Override
public StringBuilder append(CharSequence s) {
super.append(s);
return this;
}