1.#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
2.
3.线程一旦start,就不能再次start(人死不能复生。。)。