Code example for AtomicLong

0
    private boolean isTrimPending;
    private final Object lock;
    private AtomicLong lastClearCacheTime = new AtomicLong(0);
 
    // The value of tag should be a final String that works as a directory name. 
    public FileLruCache(Context context, String tag, Limits limits) {
        this.tag = tag;
        this.limits = limits;
        this.directory = new File(context.getCacheDir(), tag);
        this.lock = new Object();
 
        // Ensure the cache dir exists 
        if (this.directory.mkdirs() || this.directory.isDirectory()) {
            // Remove any stale partially-written files from a previous run 
            BufferFile.deleteAll(this.directory);
        } 
    } 
 
    // This is not robust to files changing dynamically underneath it and should therefore only be used 
    // for test code.  If we ever need this for product code we need to think through synchronization. 
Stop searching for code, let great code find you!  Add Codota to your java IDE