> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/java/java.lang-package-and-useful-class/stringbuilder-class.md).

# StringBuilder class

\- StringBuffer와 비슷하다. 하지만 StringBuffer는 동기화되어있어서 멀티쓰레드에 안전하지만(thread-safe)\
\- StringBuilder는 동기화되어있지 않아서 멀티쓰레드에 안전하지 않다.\
\- 멀티 쓰레드 프로그램이 아닌 경우, 동기화는 불필요한 성능저하를 유발한다.\
\=> 싱글 쓰레드 프로그램인 경우, StringBuilder를 사용하면 성능 향상.

* 동기화 : 데이터를 보호하는 것. 멀티스레드는 n개의 작업을 동시에 하는데, 이 때 데이터를 공유하게 된다. 여러 작업을 동시에 할 때 데이터가 꼬이지 않도록 하는 것이 동기화이다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://heunnajo.gitbook.io/java/java.lang-package-and-useful-class/stringbuilder-class.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
