public int increment(int val){
  if (val < 0) {
    return decrement(-val);
  }
  lock.lock();
  int newValue=(value+=val);
  lock.unlock();
  return newValue;
}

public int increment ( int val ) { if ( val < 0 ) { return decrement ( - val ) ; } lock . lock ( ) ; int newValue = ( value += val ) ; lock . unlock ( ) ; return newValue ; }
increments the counter by val .
