Package com.sun.cldc.util

Examples of com.sun.cldc.util.Semaphore


    /**
     * Initialize shared objects.
     * @throws IllegalStateException if already initialized.
     */
    public static void init() {
        semReady = new Semaphore(0);
        semContinue = new Semaphore(0);
        init0(semReady, semContinue);
    }
View Full Code Here


    }

    // the tests

    void testOne() {
        Semaphore sema = new Semaphore(1);
        sema.acquire();
        assertTrue(true);
    }
View Full Code Here

        sema.acquire();
        assertTrue(true);
    }

    void testTwo() {
        Semaphore sema = new Semaphore(0);
        sema.release();
        sema.acquire();
        assertTrue(true);
    }
View Full Code Here

        sema.acquire();
        assertTrue(true);
    }

    void testBlock() {
        sema = new Semaphore(0);

        Blocker t1 = new Blocker(sema);

        assertTrue(! t1.isBlocked);
        t1.start();
View Full Code Here

        sema = null;
    }

    void testManyBlock() {
        sema = new Semaphore(0);
        final int NTHREADS = 10;

        Blocker ta[] = new Blocker[NTHREADS];
        for (int i = 0; i < NTHREADS; i++) {
            ta[i] = new Blocker(sema);
View Full Code Here

    /**
     * Tests semaphores are null prior to initialization.
     */
    void testNull() {
        // no initialization here!
        Semaphore s1 = IsolateSynch.getSemReady0();
        Semaphore s2 = IsolateSynch.getSemContinue0();
        assertNull(s1);
        assertNull(s2);
    }
View Full Code Here

     * Checks semaphore identities after init, null after fini.
     */
    void testInitFini() {
        IsolateSynch.init();

        Semaphore s1 = IsolateSynch.getSemReady0();
        Semaphore s2 = IsolateSynch.getSemContinue0();
        assertSame("semReady", IsolateSynch.semReady, s1);
        assertSame("semContinue", IsolateSynch.semContinue, s2);

        IsolateSynch.fini();

View Full Code Here

TOP

Related Classes of com.sun.cldc.util.Semaphore

Copyright © 2018 www.massapicom. 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.