1.GCD
//GCD
// 创建子线程dispatch_async ( dispatch_get_global_queue ( DISPATCH_QUEUE_PRIORITY_DEFAULT , 0 ), { () -> Void in
// 发送网路请求
self . sendData ()
// 主线程
dispatch_async ( dispatch_get_main_queue (), { () -> Void in
// 更新 UI
self . updateLable ()
})
})
2.NSOperationQueue
//NSOperationQueue
let myOperation = NSBlockOperation { () -> Void in
self.sendData()
}
NSOperationQueue().addOperation(myOperation)
3.NSThread
//NSThread
NSThread.detachNewThreadSelector("sendData", toTarget: self, withObject: nil)