title: Synchronizing Arrays in Java
body: <p>So i'm going to be having a Matrix of size x * y. It's going to be made of objects of a specific class.</p>
  <p>Now my conditions are that I need to be ensure that no other thread will be able to access two of the Array Locations at once. Because the thread using the Matrix will be moving from the first location to the second location and must have a lock on Both locations until the task finishes.</p>
  <p>I would be expecting to have around 1..10 threads having access to the Matrix but it could be more.
  Because so many threads will be required I will be having a ThreadPool and an executor.</p>
  <p>I was hoping something like this would be possible. I was using the objects inside the matrices as locks themselves.</p>
  <pre><code>synchronized (matrix[x][y] &amp;&amp; matrix[x][y+1]) //Where y+1 is just an example, it could be x+1, x-1.. etc.
  {
      //In here I would be doing my modifications to the locations in the matrix I have locked.
  }
  
  </code></pre>
  <p>I don't want to be locking whole rows or columns as that's not efficient for what I am attempting.</p>
  <p>Would love some discussion about this as these ideas are bouncing around in my head.</p>
  <p>Cheers.</p>