IOS第一天多线程-01pthread

***

#import "HMViewController.h"
#import <pthread.h>

@interface HMViewController ()

@end

@implementation HMViewController

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

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // 创建线程
    pthread_t myRestrict;
    pthread_create(&myRestrict, NULL, run, NULL);
}

@end

 

posted @ 2015-09-08 17:51  iso  阅读(131)  评论(0编辑  收藏  举报