This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Why a is correct? The StringBuilder class was added in Java 5. It has exactly the same API as the StringBuffer class, except StringBuilder is not thread safe. In other words, its methods are not synchronized.
Joined: Aug 06, 2007
Hi I think StringBuffer is synchronized means all its method are synchronized
there can be two different thread invoking tostring method can interfere with each other thread1->sb.append("<"); thread2->sb.append("bbn,mn");
A is false because the toString() method is thread safe -- and this is true regardless of whether a string buffer or builder is used. The buffer is a local variable that doesn't escape the method, there is no way that it can be accessed by multiple threads.