*******创建线程
//线程
//第一种
/*
//线程
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(sum) object:nil];
//给线程起名字
thread.name = @"thread";
//启动线程
[thread start];
//关闭
[thread cancel];
*/
//第二种
// [NSThread detachNewThreadSelector:@selector(sum) toTarget:self withObject:nil];
//第三种
// [self performSelectorInBackground:@selector(sum) withObject:nil];
// NSOperation的子类
//第四种
NSInvocationOperation *inOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(inVocation) object:nil];
// [inOp start];
//第五种
NSBlockOperation *blOp = [NSBlockOperation blockOperationWithBlock:^{
NSLog(@"我是block");
}];
//创建队列
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
//设置最大同时执行数量
queue.maxConcurrentOperationCount = 2;
//添加事件
[queue addOperation:inOp];
[queue addOperation:blOp];