[cvs] / jsr166 / src / test / tck / AbstractExecutorServiceTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/AbstractExecutorServiceTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24, Wed Aug 25 00:07:02 2010 UTC revision 1.25, Thu Sep 16 02:54:10 2010 UTC
# Line 212  Line 212 
212    
213    
214      /**      /**
215       *  Blocking on submit(callable) throws InterruptedException if       * submit(callable).get() throws InterruptedException if interrupted
      *  caller interrupted.  
216       */       */
217      public void testInterruptedSubmit() throws InterruptedException {      public void testInterruptedSubmit() throws InterruptedException {
218          final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));          final CountDownLatch submitted    = new CountDownLatch(1);
219            final CountDownLatch quittingTime = new CountDownLatch(1);
220            final ExecutorService p
221                = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS,
222                                         new ArrayBlockingQueue<Runnable>(10));
223            final Callable<Void> awaiter = new CheckedCallable<Void>() {
224                public Void realCall() throws InterruptedException {
225                    quittingTime.await();
226                    return null;
227                }};
228            try {
229          Thread t = new Thread(new CheckedInterruptedRunnable() {          Thread t = new Thread(new CheckedInterruptedRunnable() {
230              public void realRun() throws Exception {              public void realRun() throws Exception {
231                  p.submit(new CheckedCallable<Object>() {                      Future<Void> future = p.submit(awaiter);
232                               public Object realCall()                      submitted.countDown();
233                                   throws InterruptedException {                      future.get();
                                  Thread.sleep(SMALL_DELAY_MS);  
                                  return null;  
                              }}).get();  
234              }});              }});
   
235          t.start();          t.start();
236          Thread.sleep(SHORT_DELAY_MS);              submitted.await();
237          t.interrupt();          t.interrupt();
238                t.join();
239            } finally {
240                quittingTime.countDown();
241          joinPool(p);          joinPool(p);
242      }      }
243        }
244    
245      /**      /**
246       *  get of submitted callable throws InterruptedException if callable       *  get of submitted callable throws InterruptedException if callable

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8