Package thread.reentrancy.conditions

Examples of thread.reentrancy.conditions.BoundedBuffer


public class TestBoundedBuffer extends TestCase {
    private static final long LOCKUP_DETECT_TIMEOUT = 1000;

    @Test
    public void testTakeBlocksWhenEmpty() {
        final   BoundedBuffer bb = new BoundedBuffer();
        Thread taker = new Thread() {
            public void run() {
                try {
                    Object unused = bb.take();
                    fail(); // if we get here, it's an error
                } catch (InterruptedException success) {
                }
            }
        };
        try {
             bb.put(1);
            taker.start();
            Thread.sleep(LOCKUP_DETECT_TIMEOUT);
            taker.interrupt();
            // The timed join ensures that the test completes even if
            // take gets stuck in some unexpected way.
View Full Code Here

TOP

Related Classes of thread.reentrancy.conditions.BoundedBuffer

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.