1.多线程实现方式

1.多线程实现方式_第1张图片
1.多线程方案.png

1.pthrad


//1.创建线程:传入线程和要执行的方法(run)
    pthread_t thread;
    pthread_create(&thread, NULL, run, NULL);

2.NSThrad



- (void)createThread3
{
    [self performSelectorInBackground:@selector(run:) withObject:@"jack"];
}

- (void)createThread2
{
    [NSThread detachNewThreadSelector:@selector(run:) toTarget:self withObject:@"rose"];
}

- (void)createThread1
{
        // 创建线程
        NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(run:) object:@"jack"];
        // 启动线程
        [thread start];
}

- (void)run:(NSString *)param
{
    
}

你可能感兴趣的:(1.多线程实现方式)