iOS Concurrency | Introduction | Options

Concurrency is two sided-weapon, that you should master and learn how to use because it will help you to write efficient code with fast execution but if you are misusing it, then results will be poor app performance, crashes etc.

So before writing code think about the problem, why do we need that and which API do you need to resolve it.

In iOS, we have different APIs that we can be used. But wait here the question is why do we need Concurrency?

  • Utilize iOS Hardware: Now all of the iOS devices are with multi-core processors that allow developers to execute multiple tasks parallel. So here we can earn lots of benefits.
  • Better User Experience: Code for call multiple web services, handle IO and some heavy tasks etc will freeze UI and make your app nonresponsive so if as a user I face this I will close the app for sure, but with concurrency, all tasks can be done in the background without hanging the main thread.
  • APIs like NSOperation and Dispatch Queues makes it really easy: Earlier creating and managing threads is not easy that’s the reason everyone gets scared when they hear about concurrency. Another major advantage of APIs is, it will also help you to manage synchronization to avoid the race condition, it happens with two threads try to access the shared resource.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s