X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD2%2FMain.java;h=e7bd9638d3ce91f39700834fe09ee9679c407839;hb=2c648f756e35448bf69e8a09670219bfc4b2fd52;hp=9e4fba5e97c7149ad19024311fd38e5eaa2b4e72;hpb=f734b9878de62b987da4922fa796a691d16680ce;p=TD_SR.git diff --git a/TD2/Main.java b/TD2/Main.java index 9e4fba5..e7bd963 100644 --- a/TD2/Main.java +++ b/TD2/Main.java @@ -1,19 +1,45 @@ -import java.io.*; - - -public class Main { - - - public static void main (String[] args) { - - ClientSimplifie client = new ClientSimplifie(); - - client.sendMsg("Line 1 Line 2"); - String msg = client.receiveMsg(); - System.out.println(msg); - - client.closeRWIO(); - - } - -} +import java.io.*; + + +public class Main { + + private static void main1() { + SocketClient client = new SocketClient(); + + try { + client.sendMsg("Line 1 Line 2"); + String msg = client.receiveMsg(); + System.out.println(msg); + } + catch (Exception e) { + System.err.println("Exception: " + e); + } + finally { + client.closeRWIO(); + } + } + + + public static void main (String[] args) { + + try { + SocketClient client = new SocketClient(); + ThreadClientSend thCS = new ThreadClientSend(client); + thCS.setMsg("Line1 Line2"); + Thread thS = new Thread(thCS); + Thread thR = new Thread(new ThreadClientReceive(client)); + thS.setName("thS"); + thS.start(); + thR.setName("thR"); + thR.start(); + } + catch (Exception e) { + System.err.println("Exception: " + e); + } + finally { + client.closeRWIO(); + } + + } + +}