Code example for AtomicBoolean

Methods: compareAndSet

0
         * If we're already writing a snapshot, don't bother enqueueing another 
         * request right now. This will reduce the number of individual 
         * snapshots and in turn the total amount of memory consumed (one big 
         * snapshot is smaller than N subset snapshots). 
         */ 
        if (pending.compareAndSet(false, true)) {
            snapshotWriter.execute(new Runnable() {
                public void run() { 
                    try { 
                        writeSnapshotFile(processName, packageInfo);
                    } finally { 
                        pending.set(false);
                    } 
                } 
            }); 
        } 
    } 
 
    /** 
     * Writes the zygote's snapshot to internal storage if profiling is enabled. 
     */