X-Git-Url: https://git.piment-noir.org/?p=TD_SR.git;a=blobdiff_plain;f=TD2%2Fclient%2FMain.java;h=08300b7139c8f0b0236905b11561d8a19822862c;hp=81a31fb2e99b07607d82e5e10065039b5c2f2249;hb=c4aaaecaa30716d0bc52f859f799880e5a37b027;hpb=e018d1ec033513412d9b3628a7d6701a48725382 diff --git a/TD2/client/Main.java b/TD2/client/Main.java index 81a31fb..08300b7 100644 --- a/TD2/client/Main.java +++ b/TD2/client/Main.java @@ -4,7 +4,7 @@ import java.io.*; public class Main { /** - * Main for testing ClientSimplifie + * main for testing ClientSimplifie */ private static void main1() { ClientSimplifie client = null; @@ -39,7 +39,10 @@ public class Main { } } - public static void main (String[] args) { + /** + * main for text based message broadcasting + */ + public static void main2() { SocketClient client = null; Thread thS = null; Thread thR = null; @@ -69,4 +72,34 @@ public class Main { } } + public static void main(String[] args) { + SocketClient client = null; + Thread thS = null; + Thread thR = null; + + try { + client = new SocketClient(); + thS = new Thread(new ThreadClientoSend(client)); + thR = new Thread(new ThreadClientoReceive(client)); + thS.setName("thoS"); + thS.start(); + thR.setName("thoR"); + thR.start(); + } + catch (Exception e) { + System.err.println("Exception: " + e); + } + finally { + try { + thS.join(); + thR.join(); + } + catch (InterruptedException e) { + System.err.println("InterruptedException: " + e); + e.printStackTrace(); + } + client.closeRWIO(); + } + } + }