*******創建線程
//線程
//第一種
/*
//線程
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];