在串行队列中使用异步任务
Using Async Task in a Serial Queue
是否可以在串行队列中添加异步任务?
我想知道如果你创建一个串行队列,并添加一些异步任务,这个队列是否将这些异步任务视为同步任务?
串行队列将等待上一个操作完成。
从实际documentation:
Serial queues ... execute one task
at a time in the order in which they are added to the queue. The
currently executing task runs on a distinct thread (which can vary
from task to task) that is managed by the dispatch queue. ...
您可以进行 运行 "async" 的操作,但它们将是连续的。
在图像 "Async on some thread" 的示例中,将始终在 "sync" 之前打印,因为 myQueue 是 serial
是否可以在串行队列中添加异步任务?
我想知道如果你创建一个串行队列,并添加一些异步任务,这个队列是否将这些异步任务视为同步任务?
串行队列将等待上一个操作完成。
从实际documentation:
Serial queues ... execute one task at a time in the order in which they are added to the queue. The currently executing task runs on a distinct thread (which can vary from task to task) that is managed by the dispatch queue. ...
您可以进行 运行 "async" 的操作,但它们将是连续的。
在图像 "Async on some thread" 的示例中,将始终在 "sync" 之前打印,因为 myQueue 是 serial