PS: @tinman - I ain't preaching doc

No, I haven't read it (don't have as much time to expand myself as I would like), but I did get quite interested in his work on Creatures. Pretty clever stuff in there.dmoc wrote:That is sad, given the topic. PS: I particularly like the "Fear Kevin" link but can't decide whether you are fan or foe. Related: have you read Steve Grand's book "Creation: life and how to make it"?
Reading variables should be safe, but be careful with strings because it is the string buffer which is not thread safe, not just the string itself.aszid wrote:hmm... i thought of another question that i "think" i know the answer to... but i'm not sure... can reading a variable (string or otherwise) from 2 threads at the same time cause problems, or is it only writing to the variable?
Code: Select all
Global a,b,c,text$
Procedure testme(string$)
Repeat
Repeat
If a = 0
a = 1
Repeat
Delay(1)
Until b = 1
text$+"bleh "
c = 1
EndIf
Until c = 1
a = 0
b = 0
c = 0
Delay(1)
Until Len(text$) > 500
EndProcedure
CreateThread(@testme(),"bleh")
Repeat
If a = 1 And c = 0
b = 1
Delay(1)
ElseIf a = 0 And c = 0
text$ + "blah "
Delay(1)
EndIf
Until Len(text$) > 500
Debug text$