How String class is thread safe in java? -
public class threadstring extends thread { string str = "abc"; public void run() { str = "abc"; } }
if threads accessing above run method, reference "abc" pointing "abc" how works internally?
string
s in java immutable. aren't modifying string
, you're pointing value. point of view, it's thread safe - str
either "abc"
or "abc"
, can't invalid or illegal.
Comments
Post a Comment