Hi, how can I prevent my parent from crashing when one of its threads crashes? The following example causes the thread to crash but its father, too.
#include <iostream> #include "cc++/thread.h"
class A : public Thread { public: A() { }; protected: virtual void Run() { cout << "hello" << endl; int *p = 0; *p = 10; // force crash } };
int main() { A *a = new A(); a->Start(); while(1) sleep(1); }
thanks
I think you have to use try-catch in Run() so that you can handle the exception.
Strange, I tested it with try-catch in Run() and it still crashes.
C++ Exception handling cannot cross thread boundries.
Log in to post a comment.
Hi,
how can I prevent my parent from crashing when one of its threads crashes?
The following example causes the thread to crash but its father, too.
#include <iostream>
#include "cc++/thread.h"
class A : public Thread
{
public:
A() { };
protected:
virtual void Run()
{
cout << "hello" << endl;
int *p = 0;
*p = 10; // force crash
}
};
int main()
{
A *a = new A();
a->Start();
while(1) sleep(1);
}
thanks
I think you have to use try-catch in Run() so that you can handle the exception.
Strange, I tested it with try-catch in Run() and it still crashes.
C++ Exception handling cannot cross thread boundries.