iOSマルチスレッドpthread
pthreadはiOSマルチスレッドの最下位層の実装であり、普段の開発では使用率が極めて少ないので、簡単に紹介します.
印刷結果:
2016-03-07 22:29:0.719マルチスレッドpthread[80573:1598184]{number=2,name=(null)}
#import "ViewController.h"
#import <pthread.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
pthread_t thread;// pthread_t
void * (*funp)(void *) = fun; // void *(*)(void *)
pthread_create(&thread, NULL, funp, NULL);// pthread_create, thread ,
}
/** * pthread_create , * * @param param <#param description#> * * @return <#return value description#> */
void *fun(void *param){
NSLog(@"%@",[NSThread currentThread]);
return NULL;
}
@end
印刷結果:
2016-03-07 22:29:0.719マルチスレッドpthread[80573:1598184]{number=2,name=(null)}