2
Answers

Sharing data between threads of different methods

D L

D L

11y
1.4k
1
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)