"Locking is considered a pessimistic approach - you're assuming the worst case, that something else will try and change your value while you do, and so you lock them out so that you can guarantee you don't waste your operation. Compare-and-swap is an optimistic approach - you assume that mostly nothing else is going to change the value when you are, so it's best to just give it a go, and deal with (hopefully) the odd failure with a retry"
"Multidimensional arrays (in Java) are arrays of arrays, so not necessarily close in physical memory. You can convert a multidimensional array to a linear array, e.g. using a calculated index like array[ROWS * col + row]. Make sure the inner loop is iterating over sequential elements, if you get this the wrong way round you'll just get cache misses all the time (i.e. NOT array[COLS * row + col], but array[ROWS * col + row] where the inner loop is for (int row=0; row < ROWS; row++)"