Code example for ConcurrentMap

Methods: get, putIfAbsent

0
        files.clear();
    } 
 
    protected ConcurrentMap<FileName, FileObject> getOrCreateFilesystemCache(FileSystem filesystem)
    { 
        ConcurrentMap<FileName, FileObject> files = filesystemCache.get(filesystem);
        if (files == null)
        { 
            filesystemCache.putIfAbsent(filesystem, new ConcurrentHashMap<FileName, FileObject>());
            files = filesystemCache.get(filesystem);
        } 
 
        return files;
    } 
 
    @Override 
    public void close() 
    { 
        super.close(); 
 
        filesystemCache.clear();