[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with Thread::isRunning()
From: |
Mathias Biere |
Subject: |
Problem with Thread::isRunning() |
Date: |
Tue, 31 Jul 2001 15:38:02 +0200 |
Hi,
I'm new to CommonC++ and have problems using the Thread class.
In the following piece of code Thread::isRunning() does not return false
if the thread leaves its Run() method. I guess this is the purpose of
isRunning()? (The main program continues printing "#" every second after the
thread has printed "Final()"... )
I am using CommonC++ 1.4.3 on Linux 2.4.4 and Windows.
###########################################
class MyThread: public Thread
{
virtual void Run();
virtual void Final();
};
void MyThread::Run()
{
for(int i=0;i<5;i++)
{
Sleep(1000);
cout<<"."<<endl;
}
cout<<"Thread finishes"<<endl;
}
void MyThread::Final()
{
cout<<"Final()"<<endl;
}
int main()
{
MyThread* mt=new MyThread;
mt->Start();
while(mt->isRunning())
{
cout<<"#"<<endl;
sleep(1);
}
cout<<"Finished"<<endl;
delete mt;
}
#######################################
Many thanks if anyone can tell me what's wrong.
Mathias Biere
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Problem with Thread::isRunning(),
Mathias Biere <=