test/jdk/java/nio/channels/Selector/RacyDeregister.java
changeset 55525 c9093341cfe2
parent 50794 0ab1cac936b8
equal deleted inserted replaced
55524:b279ae9843b8 55525:c9093341cfe2
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    38  * @summary SelectionKey.interestOps does not update interest set on Windows.
    38  * @summary SelectionKey.interestOps does not update interest set on Windows.
    39  * @author Frank Ding
    39  * @author Frank Ding
    40  * @run main/timeout=1200 RacyDeregister
    40  * @run main/timeout=1200 RacyDeregister
    41  */
    41  */
    42 public class RacyDeregister {
    42 public class RacyDeregister {
    43 
       
    44     // FIXME: NUM_OUTER_LOOP_ITERATIONS should be reverted to the hard-coded
       
    45     // value 15 when JDK-8161083 is resolved as either a bug or a non-issue.
       
    46     static final int NUM_OUTER_LOOP_ITERATIONS =
       
    47         System.getProperty("os.name").startsWith("Windows") ? 150 : 15;
       
    48 
    43 
    49     // 90% of 1200 second timeout as milliseconds
    44     // 90% of 1200 second timeout as milliseconds
    50     static final int TIMEOUT_THRESHOLD_MILLIS = 1200*900;
    45     static final int TIMEOUT_THRESHOLD_MILLIS = 1200*900;
    51 
    46 
    52     // Time at start of main().
    47     // Time at start of main().
    88         // thread that will be changing key[0].interestOps to OP_READ | OP_WRITE
    83         // thread that will be changing key[0].interestOps to OP_READ | OP_WRITE
    89         new Thread() {
    84         new Thread() {
    90 
    85 
    91             public void run() {
    86             public void run() {
    92                 try {
    87                 try {
    93                     for (int k = 0; k < NUM_OUTER_LOOP_ITERATIONS; k++) {
    88                     for (int k = 0; k < 15; k++) {
    94                         System.out.format("outer loop %3d at %7d ms%n", k,
    89                         System.out.format("outer loop %3d at %7d ms%n", k,
    95                             System.currentTimeMillis() - t0);
    90                             System.currentTimeMillis() - t0);
    96                         System.out.flush();
    91                         System.out.flush();
    97                         for (int i = 0; i < 10000; i++) {
    92                         for (int i = 0; i < 10000; i++) {
    98                             synchronized (notifyLock) {
    93                             synchronized (notifyLock) {