< prev index next >

test/jdk/java/net/MulticastSocket/MultiDead.java

Print this page
rev 51731 : imported patch 8210732


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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 /**
  25  * @test
  26  * @bug 8072466
  27  * @summary Deadlock when initializing MulticastSocket and DatagramSocket
  28  * @library /lib/testlibrary
  29  * @library /test/lib
  30  * @build jdk.testlibrary.*
  31  * @run main/othervm MultiDead
  32  */
  33 
  34 import java.net.DatagramSocket;
  35 import java.net.MulticastSocket;
  36 import java.util.concurrent.atomic.AtomicBoolean;
  37 import java.util.concurrent.atomic.AtomicReference;
  38 import java.util.concurrent.CountDownLatch;
  39 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  40 import jdk.test.lib.JDKToolLauncher;
  41 import jdk.testlibrary.Utils;
  42 
  43 public class MultiDead {
  44     private static final int THREAD_PAIR_COUNT = 4;
  45     private static final int CHILDREN_COUNT = 20;
  46     // at least 2.5 seconds for a child to complete
  47     private static final long CHILD_TIMEOUT = 2500;
  48     private static final long TIMEOUT =
  49         Utils.adjustTimeout(CHILDREN_COUNT * CHILD_TIMEOUT * 2);
  50 
  51     public static void main(String[] args) throws Throwable {
  52         if (args.length == 0 || args[0].equals("parent")) {
  53             parentProcess();
  54         }
  55 
  56         if (args.length > 0 && args[0].equals("child")) {
  57             childProcess();
  58         }
  59     }
  60 
  61     private static void parentProcess() throws Throwable {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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 /**
  25  * @test
  26  * @bug 8072466
  27  * @summary Deadlock when initializing MulticastSocket and DatagramSocket

  28  * @library /test/lib

  29  * @run main/othervm MultiDead
  30  */
  31 
  32 import java.net.DatagramSocket;
  33 import java.net.MulticastSocket;
  34 import java.util.concurrent.atomic.AtomicBoolean;
  35 import java.util.concurrent.atomic.AtomicReference;
  36 import java.util.concurrent.CountDownLatch;
  37 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  38 import jdk.test.lib.JDKToolLauncher;
  39 import jdk.test.lib.Utils;
  40 
  41 public class MultiDead {
  42     private static final int THREAD_PAIR_COUNT = 4;
  43     private static final int CHILDREN_COUNT = 20;
  44     // at least 2.5 seconds for a child to complete
  45     private static final long CHILD_TIMEOUT = 2500;
  46     private static final long TIMEOUT =
  47         Utils.adjustTimeout(CHILDREN_COUNT * CHILD_TIMEOUT * 2);
  48 
  49     public static void main(String[] args) throws Throwable {
  50         if (args.length == 0 || args[0].equals("parent")) {
  51             parentProcess();
  52         }
  53 
  54         if (args.length > 0 && args[0].equals("child")) {
  55             childProcess();
  56         }
  57     }
  58 
  59     private static void parentProcess() throws Throwable {


< prev index next >