I have a question about how to handle locking parts of a matrix. First, I guess I should use the term 2d-Array rather than matrix so that people aren't getting the mathematical idea of a matrix. My data structure is just a 2d-Array of numbers and not being treated like a mathematical matrix.

Lets say in my matrix I need to update one element and I need it to be locked while updating (I cannot use an atomic operation here), but I don't want to lock the entire matrix because I want another thread to be able to update another element in a different part of the matrix. Does it make sense for me to have a matrix of mutexs in parallel with the matrix and then just grab a spin lock for the element when I need to work with it? Or is there a smarter way to do what I want to do?

Mike