[JAVA-13958] Minor style changes + aligned code with article (#12889)
Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
parent
adbb7e27bc
commit
7313894322
@ -12,8 +12,9 @@ public class Data {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
System.out.println("Thread Interrupted");
|
||||
Thread.currentThread()
|
||||
.interrupt();
|
||||
System.err.println("Thread Interrupted");
|
||||
}
|
||||
}
|
||||
transfer = true;
|
||||
@ -28,8 +29,9 @@ public class Data {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
System.out.println("Thread Interrupted");
|
||||
Thread.currentThread()
|
||||
.interrupt();
|
||||
System.err.println("Thread Interrupted");
|
||||
}
|
||||
}
|
||||
transfer = false;
|
||||
|
@ -10,18 +10,18 @@ public class Receiver implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for(String receivedMessage = load.receive();
|
||||
!"End".equals(receivedMessage) ;
|
||||
receivedMessage = load.receive()) {
|
||||
for (String receivedMessage = load.receive(); !"End".equals(receivedMessage); receivedMessage = load.receive()) {
|
||||
|
||||
System.out.println(receivedMessage);
|
||||
|
||||
//Thread.sleep() to mimic heavy server-side processing
|
||||
try {
|
||||
Thread.sleep(ThreadLocalRandom.current().nextInt(1000, 5000));
|
||||
Thread.sleep(ThreadLocalRandom.current()
|
||||
.nextInt(1000, 5000));
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
System.out.println("Thread Interrupted");
|
||||
Thread.currentThread()
|
||||
.interrupt();
|
||||
System.err.println("Thread Interrupted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,23 +10,19 @@ public class Sender implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String packets[] = {
|
||||
"First packet",
|
||||
"Second packet",
|
||||
"Third packet",
|
||||
"Fourth packet",
|
||||
"End"
|
||||
};
|
||||
String packets[] = { "First packet", "Second packet", "Third packet", "Fourth packet", "End" };
|
||||
|
||||
for (String packet : packets) {
|
||||
data.send(packet);
|
||||
|
||||
//Thread.sleep() to mimic heavy server-side processing
|
||||
try {
|
||||
Thread.sleep(ThreadLocalRandom.current().nextInt(1000, 5000));
|
||||
Thread.sleep(ThreadLocalRandom.current()
|
||||
.nextInt(1000, 5000));
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
System.out.println("Thread Interrupted");
|
||||
Thread.currentThread()
|
||||
.interrupt();
|
||||
System.err.println("Thread Interrupted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,9 @@ public class NetworkIntegrationTest {
|
||||
sender.join();
|
||||
receiver.join();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
System.out.println("Thread Interrupted");
|
||||
Thread.currentThread()
|
||||
.interrupt();
|
||||
System.err.println("Thread Interrupted");
|
||||
}
|
||||
|
||||
assertEquals(expected, outContent.toString());
|
||||
|
Loading…
x
Reference in New Issue
Block a user