void saveInterval() {
        int ndx = 0;
        for (int i = 0; i < SharedParameters.ROWS; i++) {
            for (int j = 0; j < SharedParameters.COLUMNS; j++) {
                sumColumns[ndx] += surfaceArray[i][j].getsurfacefinalHeight();
                sumColumnsBedrock[ndx] += surfaceArray[i][j].getBedrock();
                sumIntervalsSediment[ndx] += (surfaceArray[i][j].getsurfacefinalHeight() - surfaceArray[i][j].getBedrock());
            }
            sumColumns[ndx] = sumColumns[ndx] / SharedParameters.COLUMNS;
            sumColumnsBedrock[ndx] = sumColumnsBedrock[ndx] / SharedParameters.COLUMNS;
            sumIntervalsSediment[ndx] = sumIntervalsSediment[ndx] / SharedParameters.COLUMNS;
            ndx += 1;
        }
        if (intervalCounter > 0) {
            if (SharedParameters.AVGVISIBLE) {
                for (int i = 0; i < SharedParameters.ROWS; i++) {
                    averageIntervals[i] = sumColumns[i];
                    averageIntervalsBedrock[i] = sumColumnsBedrock[i];
                }
                drawIntervals(ei, averageIntervals, averageIntervalsBedrock);
                drawIntervals(eis, sumIntervalsSediment);
            }
            if (SharedParameters.COLVISIBLE) {
                for (int i = 0; i < SharedParameters.ROWS; i++) {
                    columnIntervals[i] = surfaceArray[i][SharedParameters.COLINTERVALS - 1].getsurfacefinalHeight();
                    columnIntervalsBedrock[i] = surfaceArray[i][SharedParameters.COLINTERVALS - 1].getBedrock();
                    columnSediment[i] = (surfaceArray[i][SharedParameters.COLINTERVALS - 1].getsurfacefinalHeight() - surfaceArray[i][SharedParameters.COLINTERVALS - 1].getBedrock());
                }
                drawIntervals(ec, columnIntervals, columnIntervalsBedrock);
                drawIntervals(ecs, columnSediment);
            }
            if (SharedParameters.ROWVISIBLE) {
                for (int i = 0; i < SharedParameters.COLUMNS; i++) {
                    rowIntervals[i] = surfaceArray[SharedParameters.ROWINTERVALS - 1][i].getsurfacefinalHeight();
                    rowIntervalsBedrock[i] = surfaceArray[SharedParameters.ROWINTERVALS - 1][i].getBedrock();
                    rowSediment[i] = (surfaceArray[SharedParameters.ROWINTERVALS - 1][i].getsurfacefinalHeight() - surfaceArray[SharedParameters.ROWINTERVALS - 1][i].getBedrock());
                }
                drawIntervals(er, rowIntervals, rowIntervalsBedrock);
                drawIntervals(ers, rowSediment);
            }
        }
        Thread.yield();
    }