Code example for AtomicBoolean

Methods: compareAndSet

0
        try { 
            queue.put(new Toast(anchor, msg, duration));
        } catch (InterruptedException e) {
            e.printStackTrace();
        } 
        if (showing.compareAndSet(false, true)) {
            show(); 
        } 
    } 
 
    private static void show() { 
        if (queue.size() == 0) {
            showing.compareAndSet(true, false);
            return; 
        } 
        Toast t = queue.poll();
        window = new PopupWindow(t.anchor.getContext());
        window.setWidth(WindowManager.LayoutParams.FILL_PARENT);
        window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        window.setTouchable(false);
        window.setFocusable(false);