一、簡單說明
線程間通信:在1個程序中,線程往往不是孤立存在的,多個線程之間需要經常進行通信
線程間通信的展現
1個線程傳遞資料給另1個線程
在1個線程中執行完特定任務後,轉到另1個線程繼續執行任務
線程間通信常用方法
- (void)performselectoronmainthread:(sel)aselector withobject:(id)arg waituntildone:(bool)wait;
- (void)performselector:(sel)aselector onthread:(nsthread *)thr withobject:(id)arg waituntildone:(bool)wait;
線程間通信示例 – 圖檔下載下傳

代碼1:
代碼2: