multithread and c++ destructor# Programming - 葵花宝典
s*e
1 楼
Have this question, let's say I have two objects:
class A
{
~A();
void run();
}
class B
{
A a;
}
B b;
Let's say A::run() is the running function of a thread; and b is created and
running in another thread, in this same thread, we spawn another thread and
run A::run();
when program exit, ideally B should wait (or join) a::run(), let's suppose B
does not wait, so B is destructed but A::run() is still running, my
question is whether A::~A() will get called when B is destructed (even A::
run()
class A
{
~A();
void run();
}
class B
{
A a;
}
B b;
Let's say A::run() is the running function of a thread; and b is created and
running in another thread, in this same thread, we spawn another thread and
run A::run();
when program exit, ideally B should wait (or join) a::run(), let's suppose B
does not wait, so B is destructed but A::run() is still running, my
question is whether A::~A() will get called when B is destructed (even A::
run()