@Test
  public void testAppendMultiThreads() throws IOException {
    LOG.info("Starting test testAppendMultiThreads");
    // run a with mixed column families (1 and 3 versions)
    initHRegion(tableName, name.getMethodName(), new int[] { 1, 3 }, fam1, fam2);

    int numThreads = 100;
    int opsPerThread = 100;
    AtomicOperation[] all = new AtomicOperation[numThreads];
    final byte[] val = new byte[] { 1 };

    AtomicInteger failures = new AtomicInteger(0);
    // create all threads
    for (int i = 0; i < numThreads; i++) {
      all[i] = new AtomicOperation(region, opsPerThread, null, failures) {
        @Override
        public void run() {
          for (int i = 0; i < numOps; i++) {
            try {
              Append a = new Append(row);
              a.addColumn(fam1, qual1, val);
              a.addColumn(fam1, qual2, val);
              a.addColumn(fam2, qual3, val);
              a.setDurability(Durability.ASYNC_WAL);
              region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);

              Get g = new Get(row);
              Result result = region.get(g);
              assertEquals(result.getValue(fam1, qual1).length,
                result.getValue(fam1, qual2).length);
              assertEquals(result.getValue(fam1, qual1).length,
                result.getValue(fam2, qual3).length);
            } catch (IOException e) {
              e.printStackTrace();
              failures.incrementAndGet();
              fail();
            }
          }
        }
      };
    }

    // run all threads
    for (int i = 0; i < numThreads; i++) {
      all[i].start();
    }

    // wait for all threads to finish
    for (int i = 0; i < numThreads; i++) {
      try {
        all[i].join();
      } catch (InterruptedException e) {
      }
    }
    assertEquals(0, failures.get());
    Get g = new Get(row);
    Result result = region.get(g);
    assertEquals(10000, result.getValue(fam1, qual1).length);
    assertEquals(10000, result.getValue(fam1, qual2).length);
    assertEquals(10000, result.getValue(fam2, qual3).length);
  }
A thread that makes increment calls always on the same row, this.row against two column
families on this row.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java