swift 异步线程用法

//1.全局-异步回调主线程(加优先级)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
      dispatch_sync(dispatch_get_main_queue(),{
           // do something                       
      })
})
//2.全局异步回调(优先级)                            
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)){
           // do something
}
//3.异步回调主线程
dispatch_async(dispatch_get_main_queue(),{
           // do something
}


你可能感兴趣的:(swift,dispatch_async,异步线程,swift异步线程)