Linux--新线程陷入死循环,主线程让它退出

代码:

#include 
#include 
#include 

using namespace std;

void *threadRoutine(void *args)
{
    int i=0;

    while(true)
    {
        cout << "新线程:"<< (char*)args << " running ... " <= 5) break;
    }

    pthread_cancel(tid);
    cout<< " new thread cancel: "<

运行结果:

Linux--新线程陷入死循环,主线程让它退出_第1张图片

你可能感兴趣的:(Linux,linux)