Code example for AtomicReference

Methods: get, set

0
        super(dir, name);
        this.book = book;
    } 
 
    public Bitmap getImage() {
        Bitmap bitmap = ref.get();
        if (bitmap == null || bitmap.isRecycled()) {
            try { 
                bitmap = load(false);
                ref.set(bitmap);
            } catch (final OutOfMemoryError ex) {
            } 
        } 
        return bitmap;
    } 
 
    public synchronized void loadImageAsync(final Bitmap defImage, final ImageLoadingListener l) {
        final Bitmap bitmap = ref.get();
        if (bitmap != null && !bitmap.isRecycled()) {
            l.onImageLoaded(bitmap);
            return;