Code example for AtomicInteger

Methods: compareAndSet

0
    } 
 
    @Threaded 
    public void thread2() 
    { 
        assertTrue(ai.compareAndSet(1, 2));
    } 
 
    @Test 
    public void finish() 
    { 
        assertEquals(ai.get(), 3);
    } 
}