+ 4
StringBuffer vs StringBuilder
I found that StringBuffer is synchronized while StringBuilder is not Here we talk about the synchronization of what exactly? Thanks in advance :)
2 Respostas
+ 9
Synchronization is suitable when you have multiple threads running concurrently. It prevents thread interference and by that I mean to say if a thread is synchronized then it has access to all the shared resources and let's a particular thread finish it's task. So the other threads have to wait for the resources to be freed for them to execute.
So when we say that StringBuffer is synchronized then from my explanation above you can understand that it consumes more time and resource. But that makes it thread safe which is kind of an advantage.
+ 2
Well explained 👍 thanks friend