DIGE asks about Critical sections in IRC , and i did a small code to use them to avoid crashes from multilply use of strings in Threads
This snippet only works under windows, remember that in the section of entercriticalsection and Leavecriticalsection no other threads have access to the strings

Code: Select all
Global CSInitialized.l
Global CS.CRITICAL_SECTION
Global A.s
Procedure testme(P)
If CSInitialized =0
InitializeCriticalSection_(CS)
CSInitialized = 1
EndIf
While T<20
EntercriticalSection_(Cs)
;do everything now
A.s=Str(p)
Debug A.s
LeaveCriticalSection_(CS)
Delay(500)
T+1
Wend
EndProcedure
For I=1 To 10
ThreadID = CreateThread(@testme(), I)
Next I
Max=10000
t0=GetTickcount_()
While t<Max
t=GetTickcount_()-T0
Delay(100)
A.s="0"
Debug A.s
Wend