George George

George George

  • NA
  • 778
  • 0

Thread safe issue in string operation

Jan 5 2009 8:09 AM

Hello everyone,

Support I am using str1 = str2 statement, both str1 and str2 are type of string.

Then, suppose str1 is hold by thread 1 and str2 is hold by thread 2. My question is whether operation (for example, tryu to change content of the string, toupper, tolower, replacement) on str1 (from thread 1) and operaton on str2 (from thread 2) are thread safe?

My idea is it is thread safe, since even if str1 and str2 are pointing to the same string instance, but as string is immutable, i.e. each operation which will change the content of the string will make a new string. So, it is thread safe.

Am I correct?

thanks in advance,
George


Answers (2)