I would not make use of these 2 global variables. I would create 2 atomicintegers in this method, make them final so they can be accessed in your thread.

Also I would pull out this anonymous class and make it an inner class of the test. Makes the test a lot easier to read.