public void finishSegment(int segment){
synchronized (finished) {
    if (segment > finished.size()) {
      throw new IllegalArgumentException("Invalid segment passed to finishSegment");
    }
    finished.set(segment);
  }
}

public void finishSegment ( int segment ) { synchronized ( finished ) { if ( segment > finished . size ( ) ) { throw new IllegalArgumentException ( "Invalid segment passed to finishSegment" ) ; } finished . set ( segment ) ; } }
set the segment to finished
