@Test
  public void testFunctionalityUsingMultiThread() throws Exception {
    Collection<Callable> callables = new ConcurrentLinkedQueue<>();
    IntStream.range(0, 1000).parallel().forEach(i -> {
      callables.add(() -> {
        if (i % 3 == 0) {
          return add(new Random().nextInt(4));
        } else if (i % 3 == 1) {
          return remove(new Random().nextInt(4));
        } else {
          return iterateList();
        }
      });
    });

    Collection<Object> results = MultithreadedTester.runMultithreaded(callables);
    results.forEach(result -> {
      // There should not be any Exception here.
      // E.g. ArrayIndexOutOfBoundsException when multiple threads are acting.
      assertTrue(result.getClass().getName() + " was not an expected result",
          result instanceof Integer);
    });
  }
This tests concurrent modification of IndexElemArray and to make sure elementData and size are
updated atomically. Ticket# GEODE-106.
geode-core/src/test/java/org/apache/geode/cache/query/internal/index/IndexElemArrayJUnitTest.java