< prev index next >

test/jdk/java/net/URL/RacyHandler.java

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.IOException;
  25 import java.lang.reflect.*;
  26 import java.net.URL;
  27 import java.net.URLConnection;
  28 import java.net.URLStreamHandler;
  29 import java.util.concurrent.CountDownLatch;
  30 
  31 /*
  32  * @test
  33  * @bug 8213942
  34  * @summary URLStreamHandler initialization race

  35  * @run main/othervm RacyHandler
  36  * @run main/othervm RacyHandler
  37  * @run main/othervm RacyHandler
  38  */
  39 
  40 /*
  41  * This test makes reasonable effort to reproduce the race.
  42  * Run repeatedly to ensure correctness.
  43  */
  44 public class RacyHandler {
  45     static volatile boolean factorySet = false;
  46     static int NUM_THREADS = 2;
  47     static CountDownLatch cdl = new CountDownLatch(NUM_THREADS + 1);
  48 
  49     public static void main(String[] args) {
  50         RacyHandler tester = new RacyHandler();
  51         tester.runTest();
  52     }
  53 
  54     public void runTest() {




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.IOException;
  25 import java.lang.reflect.*;
  26 import java.net.URL;
  27 import java.net.URLConnection;
  28 import java.net.URLStreamHandler;
  29 import java.util.concurrent.CountDownLatch;
  30 
  31 /*
  32  * @test
  33  * @bug 8213942
  34  * @summary URLStreamHandler initialization race
  35  * @modules java.base/java.net:open
  36  * @run main/othervm RacyHandler
  37  * @run main/othervm RacyHandler
  38  * @run main/othervm RacyHandler
  39  */
  40 
  41 /*
  42  * This test makes reasonable effort to reproduce the race.
  43  * Run repeatedly to ensure correctness.
  44  */
  45 public class RacyHandler {
  46     static volatile boolean factorySet = false;
  47     static int NUM_THREADS = 2;
  48     static CountDownLatch cdl = new CountDownLatch(NUM_THREADS + 1);
  49 
  50     public static void main(String[] args) {
  51         RacyHandler tester = new RacyHandler();
  52         tester.runTest();
  53     }
  54 
  55     public void runTest() {


< prev index next >