Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicInteger.incrementAndGet()


                        // repeatedly try to process documents while some still
                        // remain
                        while (docIter.hasNext()) {
                           
                            TemporalDocument doc = docIter.next();
                            int docNumber = count.incrementAndGet();
                            long docTime = doc.timeStamp();

                            // special case for first document
                            if (docNumber == 1) {
                                curSSpaceStartTime.set(docTime);
View Full Code Here


    public static final int NUM = 1000;

    @Test
    public void testLazy() {
        AtomicInteger ai = new AtomicInteger(0);
        Lazy<String> lazyString = lazy(() -> "Value: " + ai.incrementAndGet());
        assertEquals(0, ai.get());
        assertEquals("Value: 1", lazyString.get());
        assertEquals(2, ai.incrementAndGet());
        assertEquals("Value: 1", lazyString.get());
    }
View Full Code Here

    public void testLazy() {
        AtomicInteger ai = new AtomicInteger(0);
        Lazy<String> lazyString = lazy(() -> "Value: " + ai.incrementAndGet());
        assertEquals(0, ai.get());
        assertEquals("Value: 1", lazyString.get());
        assertEquals(2, ai.incrementAndGet());
        assertEquals("Value: 1", lazyString.get());
    }

    @Test
    public void testThreadedLazy() throws InterruptedException, ExecutionException {
View Full Code Here

        for (int i = 0; i < NUM; i++) {
            es.submit(()->{
                cyclicBarrier.await();
                assertEquals("Value: 1", lazyString.get());
                assertEquals(1, executions.get());
                return attempts.incrementAndGet();
            });
        }
        es.shutdown();
        es.awaitTermination(1, TimeUnit.HOURS);
        assertEquals("Value: 1", lazyString.get());
View Full Code Here

            @Override
            public Thread newThread(Runnable r) {
                Thread t = new Thread(
                        null,
                        r,
                        "JitCask[" + m_caskPath + "] Read Thread " + m_counter.incrementAndGet(),
                        1024 * 256);
                t.setDaemon(true);
                return t;
            }

View Full Code Here

            @Override
            public Thread newThread(Runnable r) {
                Thread t = new Thread(
                        null,
                        r,
                        "JitCask[" + m_caskPath + "] Compression Thread " + m_counter.incrementAndGet(),
                        1024 * 256);
                t.setDaemon(true);
                return t;
            }

View Full Code Here

        final AtomicInteger i = new AtomicInteger(0);

        ksession.addEventListener( new DefaultAgendaEventListener() {
            public void matchCreated( MatchCreatedEvent event ) {
                i.incrementAndGet();
            }

            public void matchCancelled( MatchCancelledEvent event ) {
                i.decrementAndGet();
            }
View Full Code Here

        final AtomicInteger sai = new AtomicInteger();
        MapListener<String, String> stringsListener = new AbstractMapListener<String, String>() {
            @Override
            public void update(String key, String oldValue, String newValue) {
//                System.out.println(key + " " + oldValue + " => " + newValue);
                sai.incrementAndGet();
            }

            @Override
            public void inSync() {
//                System.out.println("inSync");
View Full Code Here

        final AtomicInteger iai = new AtomicInteger();
        MapListener<Integer, Integer> intsListener = new AbstractMapListener<Integer, Integer>() {
            @Override
            public void update(Integer key, Integer oldValue, Integer newValue) {
//                System.out.println(key + " " + oldValue + " => " + newValue);
                iai.incrementAndGet();
            }
        };
        ints2.addListener(intsListener);
        dataStore2.start();
View Full Code Here

        final AtomicInteger sai = new AtomicInteger();
        MapListener<String, String> stringsListener = new AbstractMapListener<String, String>() {
            @Override
            public void update(String key, String oldValue, String newValue) {
//                System.out.println(key + " " + oldValue + " => " + newValue);
                sai.incrementAndGet();
            }
        };
        strings2.addListener(stringsListener);

        final AtomicInteger iai = new AtomicInteger();
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.