I want to implement a mutex in Java using atomic variables. I tried implementing it using lamport bakery algorithm and it works. But I am not sure how to implement it, ...
If I have a variable from which multiple threads read and only one thread writes, do I need to have a lock around that variable? Would it crash if one thread ...
Thanks for the reminder about wrapping code with code tags. I read the article on JMM. When I look at my code, it appears to be correct since I use the synchronize key word everywhere the cacheObj is accessed. Both in getCacheObj() and refreshCache(). Can you enlighten me on what I might be missing. Thanks
Hi, I have a class that implements Runnable, and it has a constructor. As we know to ensure the change visibility of variables in different threads we need to use the "volatile" key word. So if I do not use "volatile," and contruct the object in the main thread, and then access and modify them in the run() method, could there ...