I am trying to create a few threads and pass 2 different strings to each thread. for the moment, i am using global variables but it doesnt seem to work. All 4 threads ( i create 4 threads ) report to have the same strings!
Anybody has any ideas how to overcome the problem??

This is in summary what i have :

Set string1
Set String2
CreateThread, MyThread .....

MyThread PROC

PrintString String1
PrintString String2

string1 & string2 are globals
Posted on 2002-11-28 11:54:35 by Ray
Copy, copy, copy.

If all threads use the same global variables, they will all eventually show the same data. It depends on how execution is interleaved between threads. By design, multitasking (multithreading) systems do not guarantee any interleave timing. Most systems will provide synchronizing primitives for situations where you need to prevent unwanted interleaving.

If all the threads share the same code and you want to pass different data, then you must create a thread-specific copy of each data (this includes any pointers to data). Send the address of the thread-specific copy via the lpParameter argument of CreateThread.
Posted on 2002-11-28 12:54:25 by tenkey