if (newStats == null) newStats = new Stats(); instance = newStats; synchronized (instance) { Date now = new Date(); instance.startTime = now; for (Date hour = new Date(instance.lastHour*Data.MILLIS_PER_HOUR + Data.MILLIS_PER_HOUR); hour.getTime()<now.getTime(); hour.setTime(hour.getTime() + Data.MILLIS_PER_HOUR)) { instance.bumpHour(hour);
if (newStats == null){ instance = new Stats(); } else { synchronized (instance) { instance = newStats; Date now = new Date();   if (now.getTime() >= newStats.stopTime.getTime() + 1000 * 60) { instance.startTime = now;  long hour = instance.lastHour * Data.MILLIS_PER_HOUR + Data.MILLIS_PER_HOUR; while(hour < now.getTime()){ instance.bumpHour(hour); hour += Data.MILLIS_PER_HOUR; } }
    public static void readStats(ServletContext context) {        Stats newStats = null;        try {            ObjectInputStream i = new ObjectInputStream(                                    new FileInputStream(statsFile(context)));            newStats = (Stats)i.readObject();            i.close();        } catch (FileNotFoundException e) {            context.log("GWebCache:no stats file");        } catch (Exception e) {            context.log("GWebCache:readStats", e);        }        if (newStats == null)            newStats = new Stats();        instance = newStats;        synchronized (instance) {            Date now = new Date();            instance.startTime = now;            for (Date hour = new Date(instance.lastHour*Data.MILLIS_PER_HOUR                                + Data.MILLIS_PER_HOUR);                 hour.getTime()<now.getTime();                 hour.setTime(hour.getTime() + Data.MILLIS_PER_HOUR)) {                    instance.bumpHour(hour);            }        }    }