atomic-values

Writing long and double is not atomic?!?!

Reading and writing of a single variable is atomic (language guarantee!), unless the variable is of type long or double. I was reading a course slides and i found that written. The class was about concurrency. Can anyone explain me why writing a long or a double is not an atomic operation? It really got me by surprise. ...

AtomicIntegerArray vs AtomicInteger[]

Is there any difference in meaning of AtomicIntegerArray and AtomicInteger[]? And which one is faster to use? (only thing that I noticed is that first is taking much less space, but that means that each recheck is checking boundaries of array, so that would make it slower?) Edit: In a scenario where array is pre-initialized. ...

How can I structure a table so that the field remains atomic?

I have a shopping cart in which I have to keep track of stock, and this includes stock with attributes. For example: shirt -- blue, small = 50 -- blue, medium = 22 -- blue, large = 53 -- red, small = 15 etc... These fields are currently separated by commas in the database and the IDs would be as follows: 1,3 1,4 1,5 2,3 wh...

Parallel version of loop not faster than serial version

I'm writing a program in C++ to perform a simulation of particular system. For each timestep, the biggest part of the execution is taking up by a single loop. Fortunately this is embarassingly parallel, so I decided to use Boost Threads to parallelize it (I'm running on a 2 core machine). I would expect at speedup close to 2 times the...