Hi guys..
I need advice on writing function in a multi-threaded envionment
Lets say I have a function which squares an integer.
int Square(int num)
{
// May do other things which might take long time to complete.
return num*num;
}
This function is called in threads eg ThreadA and ThreadB and sometimes, ThreadA and ThreadB may call Square function at the same time.
My concern is how do I ensure that when both threads call Square function at the same time, Square function functions correctly.
Btw, I'm using C++/CLI.
Please advice. Thanks.