I’m just curious as to the ability, issues, and practicality of having multiple threads utilize the same array or property in general.
-
Say I create a Queue() array and thread A adds items to the bottom of the array and thread B takes items off the top of the array. Is there any risk in doing this? What if I’m using foreach? If I’m using For with an iterator is it safe? What errors would/could get thrown? What do I do to prevent issues?
-
Say thread A reads a string and then concatenates it on itself. Say thread B alters the string. Is it possible for thread B to alter the string inbetween thread A reading the string and thread A doubling it. Under what circumstances would this be true or avoided?
like:
[code]
someGlobalString = “oldValue”
THREAD A
dim myString as string = someGlobalString
myString = myString + " " myString
someGlobalString = myString
THREAD B
someGlobalString = “newValue”[/code]
Would I ever have to worry about someGlobalString = “oldValue newValue” ???