本文只介绍Grand Central Dispath(GCD) 中央调度

个人认为一个GCD就够用了,可能是改版或是其他的在找之前写的多线程方法时发现不能用了,看文档之后发现改了,现在看上去更加简单易用。

DispatchQueue.global().async {  
            print("开始执行异步任务")  
            Thread.sleep(forTimeInterval: 2)  
            print("异步任务执行完毕")  
            DispatchQueue.main.async {  
                print("回到UI线程")  
            }  
        } 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2021-11-29
  • 2021-12-18
  • 2022-01-10
猜你喜欢
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
相关资源
相似解决方案