2
Reply

Sharing data between threads of different methods

D L

D L

Apr 10 2013 2:31 PM
1.4k
I am curious about the best way to share data between threads that aren't based on the same method. 


For example, if I want to share the same string(by reference) between 2 threads:

Main()
{
string shareme;
Start New Thread based on A()
Start New Thread based on B()

shareme = "Updated in main";

}

A()
{
shareme = "Updated in A";
}

B()
{
shareme = "Updated in B";
}


Thanks

Answers (2)