jdk/test/java/nio/channels/Selector/WakeupSpeed.java
changeset 5970 d4e98bbfb0be
parent 5506 202f599c92aa
child 7668 d4a77089c587
equal deleted inserted replaced
5968:4e9dd25279c7 5970:d4e98bbfb0be
    33 public class WakeupSpeed {
    33 public class WakeupSpeed {
    34 
    34 
    35     public static void main(String argv[]) throws Exception {
    35     public static void main(String argv[]) throws Exception {
    36         int waitTime = 4000;
    36         int waitTime = 4000;
    37         Selector selector = Selector.open();
    37         Selector selector = Selector.open();
       
    38         try {
       
    39             selector.wakeup();
    38 
    40 
    39         selector.wakeup();
    41             long t1 = System.currentTimeMillis();
       
    42             selector.select(waitTime);
       
    43             long t2 = System.currentTimeMillis();
       
    44             long totalTime = t2 - t1;
    40 
    45 
    41         long t1 = System.currentTimeMillis();
    46             if (totalTime > waitTime)
    42         selector.select(waitTime);
    47                 throw new RuntimeException("Test failed");
    43         long t2 = System.currentTimeMillis();
    48         } finally {
    44         long totalTime = t2 - t1;
    49             selector.close();
    45 
    50         }
    46         if (totalTime > waitTime)
       
    47             throw new RuntimeException("Test failed");
       
    48     }
    51     }
    49 
    52 
    50 }
    53 }