What is point of usage
DispatchQueue.main.async {
self.imageView.image = imageView
self.lbltitle.text = ""
}
or
DispatchQueue.main.sync {
self.imageView.image = imageView
self.lbltitle.text = ""
}
how code can run main.async if current queue is main? if main queue is serial, and there is only one main thread.
Tasks can be performed synchronously or asynchronously.
Synchronous function returns control to the current queue only after the task is finished. It blocks the queue and waits until the task is finished.
Asynchronous function returns control to the current queue(we are on main queue) right after task has been sent to be performed on the different queue(what is "different queue" in this case?). It doesn't wait until the task is finished. It doesn't block the queue.
Wouldn't it be more accurate to say that you should never call the sync() function on the current queue? It's not wrong to call sync() on the main queue if you're in another queue, if I understand correctly.