Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
}
catch (InterruptedException e) {
// this part is executed when an exception (in this example InterruptedException) occurs
}
catch (InterruptedException e) {
// this part is executed when an exception (in this example InterruptedException) occurs
+ System.out.println("InterruptedException: " + e);
}
}
System.out.println("Threads execution finished");
}
}
System.out.println("Threads execution finished");
}
catch(InterruptedException e) {
// this part is executed when an exception (in this example InterruptedException) occurs
}
catch(InterruptedException e) {
// this part is executed when an exception (in this example InterruptedException) occurs
+ System.out.println("InterruptedException: " + e);
}
String threadName = Thread.currentThread().getName();
System.out.println(threadName + " has slept for " + sleep_time + " ms for the " + (j + 1) + " times");
}
String threadName = Thread.currentThread().getName();
System.out.println(threadName + " has slept for " + sleep_time + " ms for the " + (j + 1) + " times");
+ " is waiting, size: " + nbObj);
wait();
}
+ " is waiting, size: " + nbObj);
wait();
}
- catch (InterruptedException e) {}
+ catch (InterruptedException e) {
+ System.out.println("InterruptedException: " + e);
+ }
}
nbObj++;
tampon[prem] = obj;
}
nbObj++;
tampon[prem] = obj;
+ " is waiting, size: " + nbObj);
wait();
}
+ " is waiting, size: " + nbObj);
wait();
}
- catch (InterruptedException e) {}
+ catch (InterruptedException e) {
+ System.out.println("InterruptedException: " + e);
+ }
}
Object outObj = null;
nbObj--;
}
Object outObj = null;
nbObj--;
try {
Thread.sleep(ThreadLocalRandom.current().nextInt(1001));
}
try {
Thread.sleep(ThreadLocalRandom.current().nextInt(1001));
}
- catch (InterruptedException e) {}
+ catch (InterruptedException e) {
+ System.out.println("InterruptedException: " + e);
+ }
try {
Thread.sleep(ThreadLocalRandom.current().nextInt(101));
}
try {
Thread.sleep(ThreadLocalRandom.current().nextInt(101));
}
- catch (InterruptedException e) {}
+ catch (InterruptedException e) {
+ System.out.println("InterruptedException: " + e);
+ }
try {
sock = new Socket(adresseIPServeur, portServeur);
}
try {
sock = new Socket(adresseIPServeur, portServeur);
}
- catch (IOException e) {}
+ catch (IOException e) {
+ System.out.println("IOException: " + e);
+ }
InputStream IStream = null;
try {
IStream = sock.getInputStream();
}
InputStream IStream = null;
try {
IStream = sock.getInputStream();
}
- catch (IOException e) {}
+ catch (IOException e) {
+ System.out.println("IOException: " + e);
+ }
InputStreamReader IMesg = new InputStreamReader(IStream);
lecture = new BufferedReader(IMesg);
InputStreamReader IMesg = new InputStreamReader(IStream);
lecture = new BufferedReader(IMesg);
try {
OStream = sock.getOutputStream();
}
try {
OStream = sock.getOutputStream();
}
- catch (IOException e) {}
+ catch (IOException e) {
+ System.out.println("IOException: " + e);
+ }
ecriture = new PrintWriter(OStream);
}
ecriture = new PrintWriter(OStream);
}
+ /**
+ * Send a message on the opened client socket
+ * @param msg a string containing the message to send
+ */
public void sendMsg(String msg) {
ecriture.println(msg);
ecriture.flush();
}
public void sendMsg(String msg) {
ecriture.println(msg);
ecriture.flush();
}
+ /**
+ * Receive a message sent on the opened client socket
+ * @return a string containing the received message
+ */
public String receiveMsg() {
String line = new String();
try {
//FIXME: read only the line before the ending newline
line = lecture.readLine();
}
public String receiveMsg() {
String line = new String();
try {
//FIXME: read only the line before the ending newline
line = lecture.readLine();
}
- catch (IOException e) {}
+ catch (IOException e) {
+ System.out.println("IOException: " + e);
+ }
+ /**
+ * Close all opened I/O streams attached to this object instance
+ */
public void closeRWIO() {
ecriture.close();
try {
lecture.close();
}
public void closeRWIO() {
ecriture.close();
try {
lecture.close();
}
- catch (IOException e) {}
+ catch (IOException e) {
+ System.out.println("IOException: " + e);
+ }
}
} // fin classe ClientSimplifie
}
} // fin classe ClientSimplifie