TD2: Make the IHM client with one receive thread and one send thread.
[TD_SR.git] / TD2 / IHM / Main.java
diff --git a/TD2/IHM/Main.java b/TD2/IHM/Main.java
new file mode 100644 (file)
index 0000000..af925f1
--- /dev/null
@@ -0,0 +1,40 @@
+import java.io.*;
+
+
+public class Main {
+
+       public static void main(String[] args) {
+               SocketClient client = null;
+               Thread thS = null;
+               Thread thR = null;
+               IHM clientIHM = null;
+
+               try {
+                       clientIHM = new IHM();
+                       clientIHM.go();
+                       client = new SocketClient();
+                       thS = new Thread(new ThreadIHMSend(client, clientIHM));
+                       thR = new Thread(new ThreadIHMReceive(client, clientIHM));
+                       thS.setName("thS");
+                       thS.start();
+                       thR.setName("thR");
+                       thR.start();
+               }
+               catch (Exception e) {
+                       System.err.println("Exception : " + e);
+                       e.printStackTrace();
+               }
+               finally {
+                       try {
+                               thS.join();
+                               thR.join();
+                       }
+                       catch (InterruptedException e) {
+                               System.err.println("InterruptedException: " + e);
+                               e.printStackTrace();
+                       }
+                       client.closeRWIO();
+               }
+       }
+
+}