xcode上的简单线程

来源:互联网 发布:华为怎么卸载软件 编辑:程序博客网 时间:2024/06/09 17:24
void* myThread(void* data)
{
    int i;
    for(i=0;i<3;i++)
    {
        NSLog(@"the myThread = %d",i);
    }
    return NULL;
}

void debugThread()
{
    pthread_t threadid;
    int i,ret;
    ret = pthread_create(&threadid, NULL, &myThread, NULL);
    NSLog(@"the ret = %d",ret);
    if(ret!=0)
    {
        printf ("Create pthread error!/n");
    }
    
    for(i=0;i<3;i++)
    {
        NSLog(@"the debugThread = %d",i);
    }
    pthread_join(threadid, NULL);
}
0 0
原创粉丝点击