From 74d32e612db1dfb26900d0a11a98f3a20a27ecfd Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 27 Jan 2023 22:18:54 +0100 Subject: [PATCH] Terminate loop explicitly on interrupted Make explicit that the loop terminates when the current thread is interrupted. --- server/src/main/java/com/genymobile/scrcpy/Controller.java | 2 +- .../main/java/com/genymobile/scrcpy/DeviceMessageSender.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java index 7663b1cf..3dc609f1 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Controller.java +++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java @@ -75,7 +75,7 @@ public class Controller { SystemClock.sleep(500); } - while (true) { + while (!Thread.currentThread().isInterrupted()) { handleEvent(); } } diff --git a/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java b/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java index 4ebccacc..2630652a 100644 --- a/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java +++ b/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java @@ -25,7 +25,7 @@ public final class DeviceMessageSender { } public void loop() throws IOException, InterruptedException { - while (true) { + while (!Thread.currentThread().isInterrupted()) { String text; long sequence; synchronized (this) {