Hello Friends
I wanted to know the difference between StringBuilder & StringBuffer classes and thier practical use. So,I wrote 2 code snippets in which I spawn 3 threads simultaneously which make use of StringBuilder & StringBuffer objects. When I run the code, i expect all the 3 threads to run simultaneously in case of StringBuilder & in synchronized manner in case of StringBuffer. But in BOTH the cases, they run in synchronized manner. then what is the use of StringBuffer class?:confused: (In case of String objects, all the 3 threads run simultaneeously). I will share the code snippets for your reference. Please also correct me if I'm wrong in understanding the concept of multi-threading itself. And please, also correct the code.:):)
// StringBuilder...
I wanted to know the difference between StringBuilder & StringBuffer classes and thier practical use. So,I wrote 2 code snippets in which I spawn 3 threads simultaneously which make use of StringBuilder & StringBuffer objects. When I run the code, i expect all the 3 threads to run simultaneously in case of StringBuilder & in synchronized manner in case of StringBuffer. But in BOTH the cases, they run in synchronized manner. then what is the use of StringBuffer class?:confused: (In case of String objects, all the 3 threads run simultaneeously). I will share the code snippets for your reference. Please also correct me if I'm wrong in understanding the concept of multi-threading itself. And please, also correct the code.:):)
// StringBuilder...
Very glad to have found your blog! I am pretty new to any kind of programming, and I was wondering if you would have any tips on using Eclipse for android development. For example what packages work best. Thanks again my friend!
ReplyDeleteThank you Keep Visiting :)
ReplyDeleteString is an immutable class while StringBuilder & StringBuffer are mutable classes. StringBuffer is synchronized while StringBuilder is not.
ReplyDeleteBelow link can be useful to find more differences between String, StringBuffer & StringBuilder
Difference between String, StringBuffer and StringBuilder
http://newtechnobuzzz.blogspot.com/2014/07/difference-between-string-stringbuffer.html