public void publish() {
        /*
         * Some care is required here to correctly swap the DataBuffers,
         * but not hold the synchronization object while compiling stats
         * (a potentially long computation).  This ensures that continued
         * data collection (calls to noteValue()) will not be blocked for any
         * significant period.
         */
        DataBuffer tmp = null;
        Lock l = null;
        synchronized (swapLock) {
            // Swap buffers
            tmp = current;
            current = previous;
            previous = tmp;
            // Start collection in the new "current" buffer
            l = current.getLock();
            l.lock();
            try {
                current.startCollection();
            } finally {
                l.unlock();
            }
            // Grab lock on new "previous" buffer
            l = tmp.getLock();
            l.lock();
        }
        // Release synchronizaton *before* publishing data
        try {
            tmp.endCollection();
            publish(tmp);
        } finally {
            l.unlock();
        }
    }
public void publish ( ) { DataBuffer tmp = null ; Lock l = null ; synchronized ( swapLock ) { tmp = current ; current = previous ; previous = tmp ; l = current . getLock ( ) ; l . lock ( ) ; try { current . startCollection ( ) ; } finally { l . unlock ( ) ; } l = tmp . getLock ( ) ; l . lock ( ) ; } try { tmp . endCollection ( ) ; publish ( tmp ) ; } finally { l . unlock ( ) ; } }
Swaps the data collection buffers, and computes statistics
about the data collected up til now.