A
arun.darra
Hi,
Is the following thread safe??
class Sample
{
private:
volatile int number;
public:
Sample():number(0) {}
void read()
{
++number;
// do nothing
--number;
}
};
I would like to know if the function read() were executed by multiple
threads simultaniously, would function be thread safe?
I mean would the ++ and -- operation be tomic?
Thanks
Is the following thread safe??
class Sample
{
private:
volatile int number;
public:
Sample():number(0) {}
void read()
{
++number;
// do nothing
--number;
}
};
I would like to know if the function read() were executed by multiple
threads simultaniously, would function be thread safe?
I mean would the ++ and -- operation be tomic?
Thanks