Code example for ExecutorService

Methods: execute

0
 
    public void testSynchronousExecutorService() throws Exception { 
        name1 = Thread.currentThread().getName();
 
        ExecutorService service = new SynchronousExecutorService();
        service.execute(new Runnable() {
            public void run() { 
                invoked = true;
                name2 = Thread.currentThread().getName();
            } 
        }); 
 
        assertTrue("Should have been invoked", invoked);
        assertEquals("Should use same thread", name1, name2);
    } 
 
    public void testSynchronousExecutorServiceShutdown() throws Exception { 
        ExecutorService service = new SynchronousExecutorService();
        service.execute(new Runnable() {
            public void run() { 
                invoked = true;