11/*
2- * Copyright (c) 1999, 2019 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1999, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3131 * @run main/othervm -Djava.net.preferIPv4Stack=true DeadlockTest
3232 */
3333
34- import java .net .*;
35- import java .io .*;
34+ import java .io .IOException ;
35+ import java .io .ObjectInputStream ;
36+ import java .io .ObjectOutput ;
37+ import java .io .ObjectOutputStream ;
38+ import java .net .InetAddress ;
39+ import java .net .InetSocketAddress ;
40+ import java .net .ServerSocket ;
41+ import java .net .Socket ;
42+
3643import jdk .test .lib .net .IPSupport ;
3744
3845public class DeadlockTest {
39- public static void main (String [] argv ) throws Exception {
46+ public static void main (String [] argv ) throws Exception {
4047 IPSupport .throwSkippedExceptionIfNonOperational ();
4148
4249 ServerSocket ss = new ServerSocket (0 , 0 , InetAddress .getLoopbackAddress ());
@@ -52,16 +59,9 @@ public static void main(String [] argv) throws Exception {
5259 Thread c1 = new Thread (ct );
5360 c1 .start ();
5461
55- // Wait for the client thread to finish
56- c1 .join (20000 );
57-
58- // If timeout, we assume there is a deadlock
59- if (c1 .isAlive () == true ) {
60- // Close the socket to force the server thread
61- // terminate too
62- s1 .stop ();
63- throw new Exception ("Takes too long. Dead lock" );
64- }
62+ // Wait for the client thread to finish.
63+ // If it doesn't finish then it's a sign of a deadlock
64+ c1 .join ();
6565 } finally {
6666 ss .close ();
6767 clientSocket .close ();
@@ -73,7 +73,7 @@ class ServerThread implements Runnable {
7373
7474 private static boolean dbg = false ;
7575
76- ObjectInputStream in ;
76+ ObjectInputStream in ;
7777 ObjectOutputStream out ;
7878
7979 ServerSocket server ;
0 commit comments