چرا داخل کد زیر thread تموم نمیشه ؟
من از داخل main که m رو NULL گذاشتم ولی while تا بی نهایت اجرا میشه
#include <iostream>
#include <thread>
using namespace std;
class MyClass{};
void th(MyClass *&p)
{
while (p != NULL)
{
cout << "tick" << endl;
this_thread::sleep_for(chrono::seconds(1));
}
return;
}
int main(int argc, char* argv[])
{
MyClass *m = new MyClass();
thread t1(th, m);
delete m;
m = NULL;
t1.join();
return 0;
}