IOS第一天多线程-01pthread

时间:2023-03-09 21:54:29
IOS第一天多线程-01pthread

***

#import "HMViewController.h"
#import <pthread.h> @interface HMViewController () @end @implementation HMViewController void *run(void *data)
{
for (int i = ; i<; 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