Code example for AtomicInteger

Methods: compareAndSet

0
    } 
 
    @Threaded("1") 
    public void thread1() throws InterruptedException 
    { 
        assertTrue(v1.compareAndSet(1, 2));
        c.countDown();
        c.await();
    } 
 
    @Threaded("2") 
    public void thread2() throws InterruptedException 
    { 
        assertTrue(v2.compareAndSet(1, 2));
        c.countDown();
        c.await();
    } 
 
    @Test 
    public void finish() 
    {