Concurrency in Ios Develpment
Concurrency in Ios Develpment
● Utilize device hardware: Now all devices have a multi-core processor that allows
developers to execute multiple processes in parallel. We should utilize this
feature and get benefits out of the hardware.
● Better user experience: While performing heavy tasks UI will freeze till the task
execution. When the user faces this situation, the first step that user will take is to
uninstall/close your app without a second thought. With concurrency, all these
tasks can be done in the background without changing the main thread or
disturbing your users. They can still tap on buttons, scroll and navigate through
your app, while it handles the heavy loading task in the background.
● The APIs like NSOperation and dispatch queues make it easy to use
concurrency: Creating and managing threads are not easy tasks. Another
important advantage about these APIs is that it helps you achieve
synchronization easily to avoid a race condition. Race condition happens when
multiple threads try to access the shared resource and that leads to unexpected
results. By usage of synchronization, resources are protected from being shared
between multiple threads.