jdk/test/java/net/ipv6tests/Tests.java
changeset 5151 e62028f44cf6
parent 2 90ce3da70b43
child 5506 202f599c92aa
--- a/jdk/test/java/net/ipv6tests/Tests.java	Fri Mar 12 09:06:00 2010 -0800
+++ b/jdk/test/java/net/ipv6tests/Tests.java	Tue Mar 16 10:05:51 2010 +0000
@@ -38,12 +38,25 @@
         OutputStream o1 = s1.getOutputStream();
         OutputStream o2 = s2.getOutputStream();
 
-        simpleWrite (o1, 100);
-        simpleWrite (o2, 200);
+        startSimpleWriter("SimpleWriter-1", o1, 100);
+        startSimpleWriter("SimpleWriter-2", o2, 200);
         simpleRead (i2, 100);
         simpleRead (i1, 200);
     }
 
+    static void startSimpleWriter(String threadName, final OutputStream os, final int start) {
+        (new Thread(new Runnable() {
+            public void run() {
+                try { simpleWrite(os, start); }
+                catch (Exception e) {unexpected(e); }
+            }}, threadName)).start();
+    }
+
+    static void unexpected(Exception e ) {
+        System.out.println("Unexcepted Exception: " + e);
+        e.printStackTrace();
+    }
+
     /**
      * Send a packet from s1 to s2 (ia2/s2.localPort) and check it
      * Send a packet from s2 to s1 (ia1/s1.localPort) and check it
@@ -247,13 +260,15 @@
         }
 
         private NetworkInterface getNextIf () {
-            while (ifs.hasMoreElements()) {
-                NetworkInterface nic = (NetworkInterface)ifs.nextElement();
-                try {
-                    if (nic.isUp() && !nic.isLoopback())
-                        return nic;
-                } catch (SocketException e) {
-                    // ignore
+            if (ifs != null) {
+                while (ifs.hasMoreElements()) {
+                    NetworkInterface nic = (NetworkInterface)ifs.nextElement();
+                    try {
+                        if (nic.isUp() && !nic.isLoopback())
+                            return nic;
+                    } catch (SocketException e) {
+                        // ignore
+                    }
                 }
             }