Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicReference.compareAndSet()


    }

    @Test
    public void compareAndSet() throws Exception {
        AtomicReference<String> reference = new AtomicReference();
        reference.compareAndSet(null, "test");
        assert reference.get().equals("test");

        assert reference.compareAndSet("test", "update");
        assert reference.get().equals("update");
View Full Code Here


    public void compareAndSet() throws Exception {
        AtomicReference<String> reference = new AtomicReference();
        reference.compareAndSet(null, "test");
        assert reference.get().equals("test");

        assert reference.compareAndSet("test", "update");
        assert reference.get().equals("update");

        assert !reference.compareAndSet("don't", "apply");
        assert reference.get().equals("update");
    }
View Full Code Here

        assert reference.get().equals("test");

        assert reference.compareAndSet("test", "update");
        assert reference.get().equals("update");

        assert !reference.compareAndSet("don't", "apply");
        assert reference.get().equals("update");
    }

    @Test
    public void getAndSet() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.