[Objective C] Generate a crash of race condition and solve.

  • Multi global thread access to one variable (val) at the same time :
    Write (newVal).
    Then read : Check if val == newVal.
  • Each thread initially sleeps for a random time to create the multiple access randomly. Hopefully, crash comes.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nguyen Tuan Minh

Nguyen Tuan Minh

7 Followers

iOS developer | Meditator. Be fond of logical and deep research