D L

D L

  • NA
  • 11
  • 17.4k

Sharing data between threads of different methods

Apr 10 2013 2:31 PM
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)