Last active
May 4, 2018 06:03
pthread_t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//01 pthread的定义 | |
>typedef __darwin_pthread_t pthread_t; | |
>typedef struct _opaque_pthread_t *__darwin_pthread_t; | |
>struct _opaque_pthread_t { | |
long __sig; | |
struct __darwin_pthread_handler_rec *__cleanup_stack; | |
char __opaque[__PTHREAD_SIZE__]; | |
}; | |
struct __darwin_pthread_handler_rec { | |
void (*__routine)(void *); // Routine to call | |
void *__arg; // Argument to pass | |
struct __darwin_pthread_handler_rec *__next; | |
}; | |
//02-pthread(演示) | |
#import <pthread.h> | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment