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?

strings 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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -