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

> And if you're not properly taking your locks before accessing your variables, `volatile` is not going to save you.

Yes, it will! Just because you’re accessing shared variables doesn’t mean you need locks. This is what volatile is for!

You’re blindly hoping the compiler will do the right thing for you, anyway. You must have little-to-no experience writing multi-theaded code in production, let alone anything more advanced that doesn’t rely on locks.

Nobody’s arguing that volatile somehow bypasses the cache. When it comes to multithreading, that doesn’t matter though, because the whole process works with the cache, and the CPU keeps core caches synchronized. Memory barriers do nothing here.

Seriously, you’re arguing rubbish.



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

Search: