問題文
A helper appends text inside one thread and never publishes the buffer it builds. Which of the two mutable sequence classes does the documentation ask the author to reach for, and why?
選択肢
- It asks for StringBuilder ahead of StringBuffer, because the class lacking synchronization is faster under most of the implementations for a buffer that one thread builds
- It asks for StringBuffer once the text is handed on, because the class that carries a promise of synchronization is the one meant to replace the other buffer in a single thread
- It asks for StringBuffer ahead of StringBuilder, because the class that carries a promise of synchronization keeps a smaller internal buffer under most of the implementations
- It asks for StringBuilder once StringBuffer has been handed over and measured, because the two classes part company over the operations each one is designed to publish rather than over the promise each one carries