Interrupted thread before logging (#3563)

This commit is contained in:
ramansahasi 2018-02-01 02:36:16 +05:30 committed by maibin
parent 43a4d08c36
commit 3e4b6df194
4 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,5 @@
package com.baeldung.concurrent.waitandnotify;
import org.slf4j.Logger;
public class Data {
private String packet;
@ -14,6 +12,7 @@ public class Data {
try {
wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println("Thread Interrupted");
}
}
@ -28,6 +27,7 @@ public class Data {
try {
wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println("Thread Interrupted");
}
}

View File

@ -20,6 +20,7 @@ public class Receiver implements Runnable {
try {
Thread.sleep(ThreadLocalRandom.current().nextInt(1000, 5000));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println("Thread Interrupted");
}
}

View File

@ -25,6 +25,7 @@ public class Sender implements Runnable {
try {
Thread.sleep(ThreadLocalRandom.current().nextInt(1000, 5000));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println("Thread Interrupted");
}
}

View File

@ -57,7 +57,8 @@ public class NetworkIntegrationTest {
sender.join();
receiver.join();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
System.out.println("Thread Interrupted");
}
assertEquals(expected, outContent.toString());