< prev index next >

test/jdk/java/nio/channels/Selector/RegisterDuringSelect.java

Print this page

        

@@ -26,10 +26,11 @@
  * @summary Test that channels can be registered, interest ops can changed,
  *          and keys cancelled while a selection operation is in progress.
  */
 
 import java.io.IOException;
+import java.nio.channels.ClosedSelectorException;
 import java.nio.channels.Pipe;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;

@@ -42,13 +43,18 @@
     static Callable<Void> selectLoop(Selector sel, Phaser barrier) {
         return new Callable<Void>() {
             @Override
             public Void call() throws IOException {
                 for (;;) {
+                    try {
                     sel.select();
+                    } catch (ClosedSelectorException ignore) {
+                        return null;
+                    }
                     if (sel.isOpen()) {
                         barrier.arriveAndAwaitAdvance();
+                        System.out.println("phaser in executor ...");
                     } else {
                         // closed
                         return null;
                     }
                 }
< prev index next >