Daniel Etzold - 2001-09-04

I'm using SuSE 7.2 with Common C++ 1.5.1.
How do I use the method isRunning() ??
The while loop in main of the following code always returns 1 although leaving the Run method after a few seconds.

This is the output of the test:
main: 1
A
main: 1
A
A
main: 1
A
A
exit run
final
final end
main: 1
main: 1
main: 1
main: 1

#include <cc++/thread.h>
#include <unistd.h>
#include <iostream>

class A : public Thread
{
  public:
    A() { };

    virtual void Run()
    {
      setCancel(THREAD_CANCEL_IMMEDIATE);

      for(int i=0; i<5; i++)
      {
        Sleep(500);
        cout << "A" << endl;
      }

      cout << "exit run" << endl;
    }

    virtual void Final()
    {
      cout << "final" << endl;
      Terminate();
      cout << "final end" << endl;
    }
};

int main()
{
  A* a = new A();
  a->Start();
  while(1)
  {
     cout << "main: " << a->isRunning() << endl;
     sleep(1);
  }
}