title: junit assert in thread throws exception
body: <p>What am I doing wrong that an exception is thrown instead of showing a failure, or should I not have assertions inside threads?</p>
  
  <pre><code> @Test
   public void testComplex() throws InterruptedException {
    int loops = 10;
    for (int i = 0; i &lt; loops; i++) {
     final int j = i;
     new Thread() {
      @Override
      public void run() {
       ApiProxy.setEnvironmentForCurrentThread(env);//ignore this
       new CounterFactory().getCounter("test").increment();//ignore this too
       int count2 = new CounterFactory().getCounter("test").getCount();//ignore
       assertEquals(j, count2);//here be exceptions thrown. this is line 75
      }
     }.start();
    }
    Thread.sleep(5 * 1000);
    assertEquals(loops, new CounterFactory().getCounter("test").getCount());
  }
  </code></pre>
  
  <p>StackTrace</p>
  
  <pre><code>Exception in thread "Thread-26" junit.framework.AssertionFailedError: expected:&lt;5&gt; but was:&lt;6&gt;
      at junit.framework.Assert.fail(Assert.java:47)
      at junit.framework.Assert.failNotEquals(Assert.java:277)
      at junit.framework.Assert.assertEquals(Assert.java:64)
      at junit.framework.Assert.assertEquals(Assert.java:195)
      at junit.framework.Assert.assertEquals(Assert.java:201)
      at com.bitdual.server.dao.ShardedCounterTest$3.run(ShardedCounterTest.java:77)
  </code></pre>