void setDate(int month, int day) {
if (notValidDate(month, date)) { throw; }
this.month = month; // atomic
this.day = day // atomic
}
Yet the whole function is not "atomic"/transactional/consistent, and two threads running simultaneously may surface the above error.
Of course it can ensure that it is consistent, C code can also just ensure that it is memory safe. This is just not an inherent property, and in general you will mess it up.
The only difference is that we can reliably solve memory safety issues (GC, Rusty's ownership model), but we have absolutely no way to solve concurrency issues in any model. The only solution is.. having a single thread.