Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we synchronize string builder?

Tags:

java

Java provide three string manipulation classes String,StringBuilder and StringBuffer. In which StringBuilder is not synchronize and StringBuffer is synchronize.

So I just want to ask is there a possibility to synchronize StringBuilder.

like image 349
sumit sharma Avatar asked Sep 16 '26 13:09

sumit sharma


1 Answers

Sure, just synchronise externally, either by using synchronized blocks or manually when you access the StringBuilder from multiple threads.

But why would you want to? You have StringBuffer already.

like image 145
Joey Avatar answered Sep 19 '26 03:09

Joey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!