Click here to Skip to main content
15,883,943 members
Home / Discussions / C#
   

C#

 
AnswerRe: System.String and Thread Safety Pin
User 665813-Jun-06 11:17
User 665813-Jun-06 11:17 
GeneralRe: System.String and Thread Safety Pin
Alexander Wiseman13-Jun-06 11:28
Alexander Wiseman13-Jun-06 11:28 
GeneralRe: System.String and Thread Safety Pin
Leslie Sanford13-Jun-06 11:40
Leslie Sanford13-Jun-06 11:40 
GeneralRe: System.String and Thread Safety [modified] Pin
Alexander Wiseman13-Jun-06 11:46
Alexander Wiseman13-Jun-06 11:46 
GeneralRe: System.String and Thread Safety [modified] Pin
Leslie Sanford13-Jun-06 11:58
Leslie Sanford13-Jun-06 11:58 
AnswerRe: System.String and Thread Safety [modified] Pin
Leslie Sanford13-Jun-06 11:44
Leslie Sanford13-Jun-06 11:44 
GeneralRe: System.String and Thread Safety Pin
Alexander Wiseman13-Jun-06 11:52
Alexander Wiseman13-Jun-06 11:52 
AnswerRe: System.String and Thread Safety Pin
Guffa13-Jun-06 11:46
Guffa13-Jun-06 11:46 
As strings are immutable, you can't change a string. What happens when you assign a new value to a string variable, is that the new value is a separate string object, and the reference to that object replaces the reference to the previous value.

As reading and writing references are atomic, there is no need to use a lock.

When you read the string value, you are copying the reference to the string. You can then use that reference to access the string that was the value at the moment you read the reference, without fear of anything happening to that string.


---
b { font-weight: normal; }

GeneralRe: System.String and Thread Safety Pin
Alexander Wiseman13-Jun-06 11:51
Alexander Wiseman13-Jun-06 11:51 
GeneralRe: System.String and Thread Safety Pin
Leslie Sanford13-Jun-06 12:00
Leslie Sanford13-Jun-06 12:00 
GeneralRe: System.String and Thread Safety Pin
Mr. VB.NET13-Jun-06 12:46
Mr. VB.NET13-Jun-06 12:46 
GeneralRe: System.String and Thread Safety Pin
Judah Gabriel Himango13-Jun-06 13:24
sponsorJudah Gabriel Himango13-Jun-06 13:24 
GeneralRe: System.String and Thread Safety Pin
Leslie Sanford13-Jun-06 13:36
Leslie Sanford13-Jun-06 13:36 
GeneralRe: System.String and Thread Safety Pin
Judah Gabriel Himango13-Jun-06 13:26
sponsorJudah Gabriel Himango13-Jun-06 13:26 
QuestionSharing source code between classes? Pin
Member 9613-Jun-06 10:39
Member 9613-Jun-06 10:39 
AnswerRe: Sharing source code between classes? Pin
gantww13-Jun-06 10:46
gantww13-Jun-06 10:46 
GeneralRe: Sharing source code between classes? Pin
Member 9613-Jun-06 11:38
Member 9613-Jun-06 11:38 
GeneralRe: Sharing source code between classes? Pin
Guffa13-Jun-06 11:50
Guffa13-Jun-06 11:50 
GeneralRe: Sharing source code between classes? Pin
Member 9613-Jun-06 12:11
Member 9613-Jun-06 12:11 
AnswerRe: Sharing source code between classes? Pin
Guffa13-Jun-06 13:50
Guffa13-Jun-06 13:50 
JokeRe: Sharing source code between classes? Pin
led mike13-Jun-06 11:04
led mike13-Jun-06 11:04 
AnswerRe: Sharing source code between classes? Pin
Ed.Poore13-Jun-06 11:27
Ed.Poore13-Jun-06 11:27 
GeneralRe: Sharing source code between classes? Pin
Member 9613-Jun-06 11:39
Member 9613-Jun-06 11:39 
GeneralRe: Sharing source code between classes? Pin
gantww13-Jun-06 12:47
gantww13-Jun-06 12:47 
GeneralRe: Sharing source code between classes? Pin
Ed.Poore14-Jun-06 3:14
Ed.Poore14-Jun-06 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.