title: how to unit test a synchronized method?
body: <p>Say I have such a method:</p>
  
  <pre><code>synchronized void incrementIndex() {
        index++;
  }
  </code></pre>
  
  <p>I want to unit test this method to see whether index's final value is set correctly if multiple threads simultaneously attempt to increment index. Assuming I don't know about the "synchronized" keyword in the method's declaration (and I only know the contract of the method), how can I do the test?</p>
  
  <p>p.s. I am using Mockito for writing test cases if it helps.  </p>