From 6eb529a9cf97df3ded360bfd370b26551bce2aa0 Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@nps.edu>
Date: Mon, 29 Jul 2024 12:54:24 -0700
Subject: [PATCH] warn if main() method invoked, not supported

---
 .../src/TcpExamples/TcpExample4HandlerThread.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/examples/src/TcpExamples/TcpExample4HandlerThread.java b/examples/src/TcpExamples/TcpExample4HandlerThread.java
index 2c3a128371..50d7a01e0f 100644
--- a/examples/src/TcpExamples/TcpExample4HandlerThread.java
+++ b/examples/src/TcpExamples/TcpExample4HandlerThread.java
@@ -31,9 +31,9 @@ public class TcpExample4HandlerThread extends Thread
     /** The socket connection to a client */
     Socket socket;
     
-    /** The thread constructor creates the socket from
-     * a ServerSocket, and passes one to the thread
-     * responsible for handling the connection.
+    /** 
+     * The thread constructor creates the socket from a ServerSocket, waiting for the client to connect,
+     * and passes that socket when constructing the thread responsible for handling the connection.
      * 
      * @param socket The socket connection handled by this thread
      */
@@ -41,6 +41,15 @@ public class TcpExample4HandlerThread extends Thread
     {
         this.socket = socket;
     }
+    /**
+     * Program invocation and execution starts here - but is illegal and unwanted, so warn the unsuspecting user!
+     * @param args command-line arguments
+     */
+    public static void main(String[] args)
+    {
+        System.out.println ("*** TcpExample4HandlerThread is not a standalone executable progam.");
+        System.out.println ("*** Please run TcpExample4DispatchServer instead... now exiting.");
+    }
     
     /** Handles one connection. We add an artificial slowness
      * to handling the connection with a sleep(). This means
-- 
GitLab