Skip to main content
Filter by
Sorted by
Tagged with
1954 votes
28 answers
541k views

What do atomic and nonatomic mean in property declarations? @property(nonatomic, retain) UITextField *userName; @property(atomic, retain) UITextField *userName; @property(retain) UITextField *...
Alex Wayne's user avatar
  • 188k
361 votes
7 answers
170k views

How do atomic / volatile / synchronized work internally? What is the difference between the following code blocks? Code 1 private int counter; public int getNextUniqueIndex() { return counter++...
hardik's user avatar
  • 9,369
296 votes
13 answers
293k views

I sort of understand that AtomicInteger and other Atomic variables allow concurrent accesses. In what cases is this class typically used though?
James P.'s user avatar
  • 19.7k
177 votes
5 answers
80k views

If there are two threads accessing a global variable then many tutorials say make the variable volatile to prevent the compiler caching the variable in a register and it thus not getting updated ...
David Preston's user avatar
145 votes
6 answers
136k views

Isn't atomic<bool> redundant because bool is atomic by nature? I don't think it's possible to have a partially modified bool value. When do I really need to use atomic<bool> instead of ...
user avatar
140 votes
4 answers
47k views

In general, what can we take for granted when we append to a file in UNIX from multiple processes? Is it possible to lose data (one process overwriting the other's changes)? Is it possible for data ...
Lajos Nagy's user avatar
  • 9,543
134 votes
6 answers
36k views

What is the difference between the lazySet and set methods of AtomicInteger? The documentation doesn't have much to say about lazySet: Eventually sets to the given value. It seems that the stored ...
Cheok Yan Cheng's user avatar
129 votes
4 answers
72k views

I read a chapter and I didn't like it much. I'm still unclear what the differences is between each memory order. This is my current speculation which I understood after reading the much more simple ...
user avatar
112 votes
4 answers
41k views

What is the cost of the atomic operation (any of compare-and-swap or atomic add/decrement)? How much cycles does it consume? Will it pause other processors on SMP or NUMA, or will it block memory ...
osgx's user avatar
  • 95.3k
104 votes
7 answers
85k views

Is a PostgreSQL function such as the following automatically transactional? CREATE OR REPLACE FUNCTION refresh_materialized_view(name) RETURNS integer AS $BODY$ DECLARE _table_name ALIAS FOR $...
Dónal's user avatar
  • 188k
94 votes
5 answers
21k views

Can anyone explain what is std::memory_order in plain English, and how to use them with std::atomic<>? I found the reference and few examples here, but don't understand at all. http://en....
2607's user avatar
  • 4,135
89 votes
3 answers
14k views

If a data structure has multiple elements in it, the atomic version of it cannot (always) be lock-free. I was told that this is true for larger types because the CPU can not atomically change the data ...
curiousguy12's user avatar
  • 1,817
85 votes
10 answers
56k views

If there a way to protect against concurrent modifications of the same data base entry by two or more users? It would be acceptable to show an error message to the user performing the second commit/...
Ber's user avatar
  • 42k
79 votes
2 answers
23k views

I wasn't aware of the std::atomic variables but was aware about the std::mutex (weird right!) provided by the standard; however one thing caught my eye: there are two seemingly-same (to me) atomic ...
hg_git's user avatar
  • 3,104
75 votes
6 answers
103k views

Now that C++11 has multithreading I was wondering what is the correct way to implement lazy initialized singleton without using mutexes(for perf reasons). I came up with this, but tbh Im not really ...
NoSenseEtAl's user avatar
  • 30.9k
73 votes
2 answers
3k views

From page 291 of OCP Java SE 6 Programmer Practice Exams, question 25: public class Stone implements Runnable { static int id = 1; public void run() { id = 1 - id; if (id == ...
Adam Stelmaszczyk's user avatar
70 votes
4 answers
26k views

I get that at the assembly language level instruction set architectures provide compare and swap and similar operations. However, I don't understand how the chip is able to provide these guarantees. ...
Alexander Duchene's user avatar
68 votes
3 answers
40k views

Is there a systematic way to know whether an operation in C# will be atomic or not? Or are there any general guidelines or rules of thumb?
Eric's user avatar
  • 6,046
66 votes
2 answers
28k views

I would like to know if I have something like this: def functionA(): with transaction.atomic(): #save something functionB() def functionB(): with transaction.atomic(): ...
Lara's user avatar
  • 2,256
64 votes
1 answer
17k views

All the methods of std::sync::atomic::AtomicBool take a memory ordering (Relaxed, Release, Acquire, AcqRel, and SeqCst), which I have not used before. Under what circumstances should these values be ...
yonran's user avatar
  • 19.3k
62 votes
0 answers
2k views

Consider an array like atomic<int32_t> shared_array[]. What if you want to SIMD vectorize for(...) sum += shared_array[i].load(memory_order_relaxed)?. Or to search an array for the first non-...
Peter Cordes's user avatar
61 votes
5 answers
11k views

Are C/C++ fundamental types, like int, double, etc., atomic, e.g. threadsafe? Are they free from data races; that is, if one thread writes to an object of such a type while another thread reads from ...
Carmellose's user avatar
  • 5,135
58 votes
5 answers
28k views

I've looked at the other volatile vs. Atomicxxxx questions in SO (including this one) and have read the description of java.util.current.atomic, and I am not quite satisfied with the nuances. If I'm ...
Jason S's user avatar
  • 191k
57 votes
5 answers
39k views

I am not being able to check this via experiments and could not gather it from the man pages as well. Say I have two processes, one moving(rename) file1 from directory1 to directory2. Say the other ...
Lipika Deka's user avatar
  • 3,944
55 votes
2 answers
16k views

For any std::atomic<T> where T is a primitive type: If I use std::memory_order_acq_rel for fetch_xxx operations, and std::memory_order_acquire for load operation and std::memory_order_release ...
zahir's user avatar
  • 1,434

1
2 3 4 5
81