Interrupted thread before logging (#3563)
This commit is contained in:
parent
43a4d08c36
commit
3e4b6df194
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue