Difficult subject, I know.
Let's say I have the current pseudo class for a Thread in Windows:
This class has the ability to start a new thread and execute the code that's defined in the Execute method, or when expanded a bit executes the code stored in a function pointer. (not added)
My question is now, I want to expand this class so that it has a internal boolean, and a getter + setter method for this boolean.
What am I supposed to do fo the getter and setter functions, so they can be accessed by another thread for example.
The idea is to have something like this:
So I'm aiming at something to be able to stop my thread for example by playing with external threads and data members.
Not really sure how to explain it better, but is this possible?
Let's say I have the current pseudo class for a Thread in Windows:
Code:
class TThread
{
private:
protected:
void __fastcall Execute();
public:
TThread(bool);
void ExitThread();
void StartThread();
};
My question is now, I want to expand this class so that it has a internal boolean, and a getter + setter method for this boolean.
What am I supposed to do fo the getter and setter functions, so they can be accessed by another thread for example.
The idea is to have something like this:
Code:
class TThread
{
private:
bool internalFlag;
protected:
void __fastcall Execute();
public:
TThread(bool);
void ExitThread();
void StartThread();
void SetInternalFlag(bool);
bool GetInternalFlag()
};
void __fastcall TThread::Execute()
{
while(true)
{
// do stuff
if(internflag)
{
break;
}
}
}
Not really sure how to explain it better, but is this possible?
Comment