public void testStringIntern() throws InterruptedException {
    makeStrings(1024*10);  // something greater than the capacity of the default cache size
    // makeStrings(100);  // realistic for perf testing
    int nThreads = 20;
    // final int iter=100000;
    final int iter=1000000;
    final boolean newStrings=true;
    
    // try native intern
    // StringHelper.interner = new StringInterner();

    Thread[] threads = new Thread[nThreads];
    for (int i=0; i<nThreads; i++) {
      final int seed = i;
      threads[i] = new Thread() {
        @Override
        public void run() {
          Random rand = new Random(seed);
          String[] myInterned = new String[testStrings.length];
          for (int j=0; j<iter; j++) {
            int idx = rand.nextInt(testStrings.length);
            String s = testStrings[idx];
            if (newStrings == true && rand.nextBoolean()) s = new String(s); // make a copy half of the time
            String interned = StringHelper.intern(s);
            String prevInterned = myInterned[idx];
            String otherInterned = internedStrings[idx];

            // test against other threads
            if (otherInterned != null && otherInterned != interned) {
              TestCase.fail();
            }
            internedStrings[idx] = interned;

            // test against local copy
            if (prevInterned != null && prevInterned != interned) {
              TestCase.fail();
            }
            myInterned[idx] = interned;
          }
        }
      };

      threads[i].start();
    }

    for (int i=0; i<nThreads; i++) {
      threads[i].join();
    }
  }