中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

淺談NSOperation的并發與非并發

發布時間:2020-06-26 23:35:24 來源:網絡 閱讀:466 作者:zhaoguohui000 欄目:開發技術

Operation分為并發和非并發兩種,也即相對caller線程是同步的還是異步的。對于提交到Operation queue中的operation來說,都是異步的,但是如果手動啟動operation的話,就有異步和非異步的區分了。


Although you typically execute operations by adding them to an operation queue, doing so is not required. It is also possible to execute an operation object manually by calling its start method, but doing so does not guarantee that the operation runs concurrency with the rest of your code. The isConcurrent method of the NSOperation class tells you whether an operation runs synchronously or asynchrously with respect to the thread in which its start method was called. By default, this method returns NO, which means the operation runs synchronously in the calling thread.


If you want to implement a concurrent operation - that is, one that runs asynchronously with respect to the calling thread - you must write additional code to start the operation asynchronously. For example, you might spawn a separate thread, call an asynchronous system function, or do anything else to ensure that the start method starts the task and returns immediately and, in all likeihood, before the task is finished.


Most developers should never need to implement concurrent operation objects. If you always ad your operations to an operation queue, you do not need to implement concurrent operations. When you submit a nonconcurrent operation to an operation queue, the queue itself creates a thread on which to run your operation. Thus, adding a nonconcurrent operation to an operation queue still results in the asynchronous execution of your operation object code. The ability to define concurrent operations is only necessary in cases where you need to execute the operation asynchronously without adding it to an operation queue.


For information about how to create a concurrent operation, see "Configuring Operations for Concurrent Execution" and NSOperation Class Reference.







向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

吴旗县| 南城县| 威宁| 天峻县| 鄂尔多斯市| 大埔县| 武鸣县| 农安县| 昔阳县| 昂仁县| 晋江市| 鲜城| 建始县| 尚志市| 房产| 巩义市| 赞皇县| 建瓯市| 蒲江县| 额敏县| 黎城县| 武义县| 昌乐县| 安龙县| 朝阳区| 景东| 甘德县| 工布江达县| 来宾市| 太白县| 洛宁县| 顺平县| 台南市| 梅州市| 乌拉特中旗| 漠河县| 盐山县| 景泰县| 新营市| 集贤县| 张家界市|