Skip to content

Replaced StringBuffers

Bakó A. Benjamin edited this page May 3, 2017 · 1 revision

I replaced in some classes the StringBuffers to StringBuilder. StringBuffer is synchronized, but we didnt find any classes which implements Runnable or extends Thread. As we discussed in Replace the StringBuffer to StringBuilder? issue. The operations are "almost" the same, but using synchronized methods in a single thread is overkill. So the StringBuilder is much faster than StringBuffer.

Quote from StringBuilder API: "This class [StringBuilder] provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations."

Clone this wiki locally