NSThread 多线程 三种方式
//
// ZBMainViewController.m
// TestProject
//
// Created by 张先森 on 14/12/5.
// Copyright (c) 2014年 zhibin. All rights reserved.
//
#import "ZBMainViewController.h"
@interface ZBMainViewController ()
@property(nonatomic,strong)CALayer *mylayer;
@end
@implementation ZBMainViewController
bool isopen=NO;
- (void)viewDidLoad {
[super viewDidLoad];
[self InitControls];
}
-(void)InitControls{
NSThread *thread=[NSThread currentThread];
NSLog(@"%@",thread);
NSThread *mainthread=[NSThread mainThread];
NSLog(@"%@",mainthread);
NSThread *tempthread=[[NSThread alloc] initWithTarget:self selector:@selector(run:) object:@"线程1"];
tempthread.name=@"thread1";
[tempthread start];
[NSThread detachNewThreadSelector:@selector(run:) toTarget:self withObject:@"线程2"];
[self performSelectorInBackground:@selector(run:) withObject:@"线程3"];
}
-(void)run:(NSString *)str{
NSLog(@"%@",str);
}
@end