2 ms·
99% of the time you initialize StringBuilder during a method call. Each method call stores it’s variables on the stack and each thread has its own stack. So in
by shiv86 10y ago
99% of the time you initialize StringBuilder during a method call. Each method call stores it’s variables on the stack and each thread has its own stack.
So in the above 99% usecases StringBuilder is thread safe by default.
Use cases for StringBuffer are very limited …I can’t even think of an example where I would use it.