So I'm reading an older document by Stephen Cleary, and although it's old, I'd still like to understand what he meant. It's the following document (Async and Scheduled Concurrency) and in particular I'm having problems understanding the following paragraph:
Async doesn’t play well with traditional synchronization primitives. For example, think about what happens when you await while holding a lock: the async method will return to its caller, allowing other code to run on that thread while the lock is held. If the method later resumes on the same thread (e.g., a UI context), and the “other code” attempts to take the lock, then you have a deadlock.
I don't understand the following: if the method later resumes on the same thread (let's assume the UI context) it will hence be able to release the lock. Thus no matter if the "other code" runs on the UI context or not it will be able to acquire the lock? Also, if the "other code" resumes on the 'UI context', that thread already has the lock thus acquiring it again isn't an issue.
I guess I'm not quite sure what deadlock he's speaking of.
Thanks to all