Switch CRLF to LF line endings.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 9 Mar 2018 20:56:06 +0000 (21:56 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 9 Mar 2018 20:56:06 +0000 (21:56 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TD1/exo3/BufferCirc.java
TD1/exo3/Consommateur.java
TD1/exo3/Main.java
TD1/exo3/Producteur.java
TD2/Main.java

index ebfb2877016fdc978bf4e47b6d61ba9b9e2cb6c3..45710851abd01031ba4f05516ddf75b86c1ffd5e 100644 (file)
@@ -1,68 +1,68 @@
-\r
-\r
-/**\r
- * implementation du producteur consommateur avec un buffer circulaire\r
- */\r
-public class BufferCirc {\r
-\r
-       private Object[] tampon;\r
-       private int taille;\r
-       private int prem, der, nbObj;\r
-\r
-\r
-       public BufferCirc (int t) {\r
-               taille = t;\r
-               tampon = new Object[taille];\r
-               prem = 0;\r
-               der = 0;\r
-               nbObj = 0;\r
-       }\r
-\r
-\r
-       public boolean isEmpty() {\r
-               return nbObj == 0;\r
-       }\r
-\r
-\r
-       public boolean isFull() {\r
-               return nbObj == taille;\r
-       }\r
-\r
-\r
-       public synchronized void depose(Object obj) {\r
-               while(isFull()) {\r
-                       try {\r
-                               System.out.println("Buffer is full: " + Thread.currentThread().getName()\r
-                                    + " is waiting, size: " + nbObj);\r
-\r
-                               wait();\r
-                       }\r
-                       catch (InterruptedException e) {}\r
-               }\r
-               nbObj++;\r
-               tampon[prem] = obj;\r
-               prem = (prem + 1) % taille;\r
-               //System.out.println(Thread.currentThread().getName() + " a depose " + (Integer)obj);\r
-               notifyAll();\r
-       }\r
-\r
-\r
-       public synchronized Object preleve() {\r
-               while(isEmpty()) {\r
-                       try {\r
-                               System.out.println("Buffer is empty: " + Thread.currentThread().getName()\r
-                                    + " is waiting, size: " + nbObj);\r
-                               wait();\r
-                       }\r
-                       catch (InterruptedException e) {}\r
-               }\r
-               Object outObj = null;\r
-               nbObj--;\r
-               outObj = tampon[der];\r
-               der = (der + 1) % taille;\r
-               //System.out.println(Thread.currentThread().getName() + " a preleve " + (Integer)outObj);\r
-               notifyAll();\r
-               return outObj;\r
-       }\r
-\r
-} // fin class BufferCirc\r
+
+
+/**
+ * implementation du producteur consommateur avec un buffer circulaire
+ */
+public class BufferCirc {
+
+       private Object[] tampon;
+       private int taille;
+       private int prem, der, nbObj;
+
+
+       public BufferCirc (int t) {
+               taille = t;
+               tampon = new Object[taille];
+               prem = 0;
+               der = 0;
+               nbObj = 0;
+       }
+
+
+       public boolean isEmpty() {
+               return nbObj == 0;
+       }
+
+
+       public boolean isFull() {
+               return nbObj == taille;
+       }
+
+
+       public synchronized void depose(Object obj) {
+               while(isFull()) {
+                       try {
+                               System.out.println("Buffer is full: " + Thread.currentThread().getName()
+                                    + " is waiting, size: " + nbObj);
+
+                               wait();
+                       }
+                       catch (InterruptedException e) {}
+               }
+               nbObj++;
+               tampon[prem] = obj;
+               prem = (prem + 1) % taille;
+               //System.out.println(Thread.currentThread().getName() + " a depose " + (Integer)obj);
+               notifyAll();
+       }
+
+
+       public synchronized Object preleve() {
+               while(isEmpty()) {
+                       try {
+                               System.out.println("Buffer is empty: " + Thread.currentThread().getName()
+                                    + " is waiting, size: " + nbObj);
+                               wait();
+                       }
+                       catch (InterruptedException e) {}
+               }
+               Object outObj = null;
+               nbObj--;
+               outObj = tampon[der];
+               der = (der + 1) % taille;
+               //System.out.println(Thread.currentThread().getName() + " a preleve " + (Integer)outObj);
+               notifyAll();
+               return outObj;
+       }
+
+} // fin class BufferCirc
index 28a5efa78427e74ebc6f5aab516fc4f4a3b115fd..480134976bcecd810a20ae7db3fdfbdfc4fb0eb4 100644 (file)
@@ -1,33 +1,33 @@
-import java.util.concurrent.ThreadLocalRandom;\r
-\r
-\r
-public class Consommateur implements Runnable {\r
-\r
-       private BufferCirc buffer;\r
-\r
-       public Consommateur(BufferCirc b) {\r
-               buffer = b;\r
-       }\r
-\r
-       public Consommateur(BufferCirc b, String name) {\r
-               buffer = b;\r
-               setThName(name);\r
-       }\r
-\r
-       public void setThName(String name) {\r
-               Thread.currentThread().setName(name);\r
-       }\r
-\r
-       public void run() {\r
-               Integer val;\r
-               while (true) {\r
-                       val = (Integer)buffer.preleve();\r
-                       System.out.println (Thread.currentThread().getName() + " a preleve " + val);\r
-                       try {\r
-                               Thread.sleep(ThreadLocalRandom.current().nextInt(1001));\r
-                       }\r
-                       catch (InterruptedException e) {}\r
-               }\r
-       }\r
-\r
-} // fin classe Consommateur\r
+import java.util.concurrent.ThreadLocalRandom;
+
+
+public class Consommateur implements Runnable {
+
+       private BufferCirc buffer;
+
+       public Consommateur(BufferCirc b) {
+               buffer = b;
+       }
+
+       public Consommateur(BufferCirc b, String name) {
+               buffer = b;
+               setThName(name);
+       }
+
+       public void setThName(String name) {
+               Thread.currentThread().setName(name);
+       }
+
+       public void run() {
+               Integer val;
+               while (true) {
+                       val = (Integer)buffer.preleve();
+                       System.out.println (Thread.currentThread().getName() + " a preleve " + val);
+                       try {
+                               Thread.sleep(ThreadLocalRandom.current().nextInt(1001));
+                       }
+                       catch (InterruptedException e) {}
+               }
+       }
+
+} // fin classe Consommateur
index 78c3b030fa691f8df3b2bff28acdf4257b76d01c..af0ba12ee84f810585cdc533d754c19a97c7f7f8 100644 (file)
@@ -1,27 +1,27 @@
-\r
-import java.util.ArrayList;\r
-\r
-\r
-public class Main {\r
-\r
-\r
-       public static void main (String[] args) {\r
-               final int BUFFER_SIZE = 1;\r
-               final int PROD_NUMBER = 20;\r
-               final int CONS_NUMBER = 20;\r
-               BufferCirc b = new BufferCirc(BUFFER_SIZE);\r
-               Thread[] P = new Thread[PROD_NUMBER];\r
-               Thread[] C = new Thread[CONS_NUMBER];\r
-               for (int i = 0; i < P.length; i++) {\r
-                       P[i] = new Thread(new Producteur(b));\r
-                       P[i].setName("P" + i);\r
-                       P[i].start();\r
-               }\r
-               for (int i = 0; i < C.length; i++) {\r
-                       C[i] = new Thread(new Consommateur(b));\r
-                       C[i].setName("C" + i);\r
-                       C[i].start();\r
-               }\r
-       }\r
-\r
-}\r
+
+import java.util.ArrayList;
+
+
+public class Main {
+
+
+       public static void main (String[] args) {
+               final int BUFFER_SIZE = 1;
+               final int PROD_NUMBER = 20;
+               final int CONS_NUMBER = 20;
+               BufferCirc b = new BufferCirc(BUFFER_SIZE);
+               Thread[] P = new Thread[PROD_NUMBER];
+               Thread[] C = new Thread[CONS_NUMBER];
+               for (int i = 0; i < P.length; i++) {
+                       P[i] = new Thread(new Producteur(b));
+                       P[i].setName("P" + i);
+                       P[i].start();
+               }
+               for (int i = 0; i < C.length; i++) {
+                       C[i] = new Thread(new Consommateur(b));
+                       C[i].setName("C" + i);
+                       C[i].start();
+               }
+       }
+
+}
index f7f3c474b57e49d830ec32e6aeed80fff028d915..47a402180d5f8c9a6fa4854bc4b3b03f76c97858 100644 (file)
@@ -1,35 +1,35 @@
-import java.util.concurrent.ThreadLocalRandom;\r
-\r
-\r
-public class Producteur implements Runnable {\r
-\r
-       private BufferCirc buffer;\r
-       private int val;\r
-\r
-\r
-       public Producteur(BufferCirc b) {\r
-               buffer = b;\r
-       }\r
-\r
-       public Producteur(BufferCirc b, String name) {\r
-               buffer = b;\r
-               setThName(name);\r
-       }\r
-\r
-       public void setThName(String name) {\r
-               Thread.currentThread().setName(name);\r
-       }\r
-\r
-       public void run() {\r
-               while (true) {\r
-                       buffer.depose(new Integer(val));\r
-                       System.out.println (Thread.currentThread().getName() +  " a depose " + val);\r
-                       val++;\r
-                       try {\r
-                               Thread.sleep(ThreadLocalRandom.current().nextInt(101));\r
-                       }\r
-                       catch (InterruptedException e) {}\r
-               }\r
-       }\r
-\r
-} // fin classe Producteur\r
+import java.util.concurrent.ThreadLocalRandom;
+
+
+public class Producteur implements Runnable {
+
+       private BufferCirc buffer;
+       private int val;
+
+
+       public Producteur(BufferCirc b) {
+               buffer = b;
+       }
+
+       public Producteur(BufferCirc b, String name) {
+               buffer = b;
+               setThName(name);
+       }
+
+       public void setThName(String name) {
+               Thread.currentThread().setName(name);
+       }
+
+       public void run() {
+               while (true) {
+                       buffer.depose(new Integer(val));
+                       System.out.println (Thread.currentThread().getName() +  " a depose " + val);
+                       val++;
+                       try {
+                               Thread.sleep(ThreadLocalRandom.current().nextInt(101));
+                       }
+                       catch (InterruptedException e) {}
+               }
+       }
+
+} // fin classe Producteur
index 9e4fba5e97c7149ad19024311fd38e5eaa2b4e72..822fb58d5ad4ed2b8ebcc536918cfdf9de17263f 100644 (file)
@@ -1,19 +1,19 @@
-import java.io.*;\r
-\r
-\r
-public class Main {\r
-\r
-\r
-       public static void main (String[] args) {\r
-\r
-               ClientSimplifie client = new ClientSimplifie();\r
-\r
-               client.sendMsg("Line 1 Line 2");\r
-               String msg = client.receiveMsg();\r
-               System.out.println(msg);\r
-\r
-               client.closeRWIO();\r
-\r
-       }\r
-\r
-}\r
+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();
+
+       }
+
+}