Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you pass an object to a method in Java, C#, whatever, and that method starts a new thread with it, you're still going to be boned if the callee starts modifying it at the same time.

Which is why the concept of thread-safe types exists. The documentation usually explicitly states if a particular container/service/anything else is safe to call from multiple threads concurrently or not, and the standard library goes to great lengths to either make the types that are expected to be used in multi-threaded scenarios thread-safe or to offer thread-safe alternatives (like ConcurrentDictionary<K, V>).

Worst case, most types are engineered in such a way that should thread-safety be violated, it would either lead to an exception or an invalid state but not to memory safety issues.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: