I wonder, would it not be possible for an IDE to detect any shared mutable objects that are used in multiple threads?
You could flag types as either
[Immutable] using attributes in .NET for example, and then those variables would never cause warnings, but any other variable that is used inside of a method invoked via
Thread would be highlighted as "possibly unsafe" unless all assignments occur inside of a
lock or something like that.
I know it wouldn't be perfect because the compiler simply can't reason about all the possible scenarios (humans barely can), but hints like these would be quite valuable, no?
Is this even feasible?