JavaFunda wrote:Yes, it does.
Below is the line written under javadocs of String class .
"Because String objects are immutable they can be shared."
Link is http://download.oracle.com/javase/6/docs/api/java/lang/String.html
Yes String are immutable but still it does not gaurantee that their wont be any thread interference in case of string.
Say if we have string object as instance variable i.e str1You're talking about changing the value of a reference variable that points to a String object. That's completely different. It's not what that quote is talking about.
Two threads enter concurrently tries to modify the str1. we are not sure what will be the final value of str1 . wondering what does the statement mean when it is saying "they can be shared."?
833545 wrote:No. That link is irrelevant. If it contradicts the facts I have already pointed out to you, it is wrong.
Refer the below link:
Strings are thread-safe and have no synchorization issues.Wrong. Don't try to tell me what I meant when I said something.
When u say about modifying the string, it does'nt mean the earlier value is been overridden with the new one, but it means the string instance variable is been assigned with the new String object reference.
833545 wrote:I don't need to. I'm not the one who is confused.No. That link is irrelevant. If it contradicts the facts I have already pointed out to you, it is wrong.i think you have not gone through the link.