Original Post
Heres something I was wondering about, suppose we have the following statement:
StringBuffer sb = new StringBuffer()
sb.append(a);
sb.append(b);
sb.append(c);
And contrast it with this code:
StringBuffer sb = new StringBuffer()
synchronized (sb) {
sb.append(a);
sb.append(b);
sb.append(c);
}
Is the second piece of code faster because the first code has to perform 3 internal locks within the stringbuffer class versus only one in second piece of code?