private void addTerm(String term){
  Integer index=termToIndex.get(term);
  if (index == null) {
synchronized (this) {
      index=termToIndex.get(term);
      if (index == null) {
        index=Integer.valueOf(termIndexCounter.getAndIncrement());
        termToIndex.put(term,index);
      }
    }
  }
}

private void addTerm ( String term ) { Integer index = termToIndex . get ( term ) ; if ( index == null ) { synchronized ( this ) { index = termToIndex . get ( term ) ; if ( index == null ) { index = Integer . valueOf ( termIndexCounter . getAndIncrement ( ) ) ; termToIndex . put ( term , index ) ; } } } }
adds the term to the list of terms and gives it an index , or if the term has already been added , does nothing .
