Hacker News new | ask | show | jobs
by pcwalton 4540 days ago
Threads with locks are fine as long as the compiler enforces that you take the lock before mutating the data (e.g. Rust). :)
1 comments

Annotalysis can do this for C++ as well. The problem is that you need to enforce an ordering on locks to avoid deadlocks. That works fine if they're all within one module. It doesn't work at all if you have to coordinate callbacks across threads from different third-party libraries.

The usual solution I've seen given for this is "Don't invoke callbacks when holding a lock." This is not a viable solution for most programs.