volatile
Is volatile int in C as good as std::atomic<int> of C++0x?
I need to have atomic variables in my program. Previously I was using std::atomi开发者_StackOverflow中文版c<int>, but the platform in which I\'m working now does not have a g++ compiler that sup[详细]
2023-03-18 02:56 分类:问答Volatile and multithreading: is the following thread-safe?
Assume there are two threads running Thread1() and Thread2() respectively.The thread 1 just sets a global flag to tell thread 2 to quit and thread 2 periodically checks if it should quit.[详细]
2023-03-17 19:30 分类:问答Instance variables and threading
I have a class like the below and am wondering, will this be thread-safe or can the main thread and the Loader thread possibly have their own copys of the mCache and therefore the get(..) method fail[详细]
2023-03-16 09:50 分类:问答volatile with release/acquire semantics
Since Java 5, the volatile keyword has release/acquire semantics to make side-effects visible to other threads (including assignments to non-volatile variables!). Take these two variables, for example[详细]
2023-03-16 02:15 分类:问答Should volatile be used with a (non-concurrent) collection?
I\'m familiar with the basic idea of volatile (to prevent compiler optimization of instructions involving values that may be accessed from multiple threads, in summary), but I\'ve noticed that example[详细]
2023-03-16 00:35 分类:问答LazyReference with double-checked locking and null handling
I\'ve been using LazyReference class for a few years (not on a regular basis of course, but sometimes it is very useful). The class can be seen here. Credits go to Robbie Vanbrabant (class author) and[详细]
2023-03-14 22:18 分类:问答volatile vs. synchronize, which one for objects? [duplicate]
This question already has answers here: Closed 11 years ago. Possible Duplicates: Difference between volatile and synchronized in JAVA (j2me)[详细]
2023-03-12 14:49 分类:问答Unprotected get function in multithreaded system - needs volatile?
I\'m working on a multi threaded program that provides access to one side of an interprocess communication system. Having never used volatile, I\'m trying to figure out its proper usage.[详细]
2023-03-10 16:53 分类:问答Volatile variable in Java
So I am reading this book titled Java Concurrency in Practice and I am stuck on this one explanation which I cannot seem to comprehend without an example. This is the quote:[详细]
2023-03-10 16:42 分类:问答Could a shared memory be updated in some thread while its value is still not visible to the main thread?
I was reading this article about volatile fields in C#. using System; using System.Threading; class Test[详细]
2023-03-10 15:26 分类:问答