Code example for AtomicBoolean

    private static final Executor snapshotWriter;
    private static final int samplingProfilerMilliseconds;
    private static final int samplingProfilerDepth;
    /** Whether or not a snapshot is being persisted. */ 
    private static final AtomicBoolean pending = new AtomicBoolean(false);
    static { 
        samplingProfilerMilliseconds = SystemProperties.getInt("persist.sys.profiler_ms", 0);
        samplingProfilerDepth = SystemProperties.getInt("persist.sys.profiler_depth", 4);
        if (samplingProfilerMilliseconds > 0) {
            File dir = new File(SNAPSHOT_DIR);
            // the directory needs to be writable to anybody to allow file writing 
            dir.setWritable(true, false);
            // the directory needs to be executable to anybody to allow file creation 
            dir.setExecutable(true, false);
            if (dir.isDirectory()) {
                snapshotWriter = Executors.newSingleThreadExecutor(new ThreadFactory() {
                        public Thread newThread(Runnable r) {
Experience pair programming with AI  Get Codota for Java