public int increment(){
  lock.lock();
  int newValue=++value;
  lock.unlock();
  return newValue;
}

public int increment ( ) { lock . lock ( ) ; int newValue = ++ value ; lock . unlock ( ) ; return newValue ; }
increments the counter by 1 .
