pthread使用举例

pthread的简单用法

void *run(void *data) {
    
    NSThread *current = [NSThread currentThread];
    
    for (int i = 0; i<20000; i++) {
        NSLog(@"run---%@", current);
    }
    
    return NULL;
}

- (IBAction)btnClick {
    // 1.获得当前的线程
    NSThread *current = [NSThread currentThread];
    NSLog(@"btnClick---%@", current);
    
    // 2.执行一些耗时操作 : 创建一条子线程
    pthread_t threadId;
    pthread_create(&threadId, NULL, run, NULL);
}

 

posted @ 2015-06-14 10:21  cn.ios  阅读(150)  评论(0)    收藏  举报