Package com.publicobject.misc.util.concurrent

Examples of com.publicobject.misc.util.concurrent.JobQueue


    /**
     * Make sure that our locks don't throw interrupted exceptions.
     */
    private void testLockInterrupt(final ReadWriteLock lock) {
        JobQueue jobQueue = new JobQueue();
        Thread jobQueueThread = new Thread(jobQueue);
        jobQueueThread.start();

        lock.writeLock().lock();

        // interrupt that thread
        jobQueueThread.interrupt();

        // create a thread that will block waiting on Lock.lock()
        JobQueue.Job result = jobQueue.invokeLater(new LockALockRunnable(lock.writeLock()));

        // make sure there's contention on the lock
        sleep(1000);

        // release the lock, this will cause our other job to finish
        lock.writeLock().unlock();

        // flush the queue
        jobQueue.flush();

        // validate that our thread didn't throw interrupted exception
        assertNull(result.getThrown());

        // validate that the thread is still interrupted
        jobQueue.invokeAndWait(new FailIfNotInterruptedRunnable());
    }
View Full Code Here

TOP

Related Classes of com.publicobject.misc.util.concurrent.JobQueue

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.