Code example for AtomicInteger

Methods: set

0
    void error() { 
        errorCount.incrementAndGet();
    } 
 
    void reset() { 
        successCount.set(0);
        errorCount.set(0);
        times.clear();
    } 
 
    void report() { 
        long total = 0;
        for (Iterator<Long> it = times.iterator(); it.hasNext(); ) {
            total += it.next();
        } 
        double average = total / (double)successCount.get();
        System.out.println("successCount=" + successCount);
        System.out.println("errorCount=" + errorCount);
        System.out.println("average=" + average);
    }