Hi,
I've searched far and wide but I haven't found exactly what I need.
I have to programs communicating through named pipelines (windows XP). One is sending strings to another. The one who's recieves inserts them into an array. Now, here's the problem: this program is multi-threaded, each thread has it's own class, and I need to make the string array visible to all the threads. So I thougth that I could pass the string array reference to the other threads so when I change it in the main thread, every other thread will see it too, but, only the last value of the array is updated! Here it is in pseudocode:
int main(){
string * strArray= new string[10];
ThreadObject obj;
obj.LoadArray(strArray);
int i=0;
while(true){
string buff=RecieveFromPipe();
strArray[i]=buff;
i=(i+1)%10;
}
}
The LoadArray function is prototyped as this:
void ThreadObj::LoadArray(string *a){
string_pointer=a;
}
Any idea? I'm sorry if I'm not perfectly clear, English is not my first language and my choice of words is very limited.
Thanks in advance,
GGAB