From 5b09e0b7ae7067f3306d72731f614c886cebea6e Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 30 Sep 2021 13:39:51 -0400 Subject: [PATCH] Move logic inside of lock --- .../src/main/java/com/livio/taskmaster/Taskmaster.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Taskmaster/src/main/java/com/livio/taskmaster/Taskmaster.java b/Taskmaster/src/main/java/com/livio/taskmaster/Taskmaster.java index d282335..bb542b4 100644 --- a/Taskmaster/src/main/java/com/livio/taskmaster/Taskmaster.java +++ b/Taskmaster/src/main/java/com/livio/taskmaster/Taskmaster.java @@ -224,9 +224,8 @@ public void run() { } private void alert() { - - if (isWaiting) { - synchronized (TASK_THREAD_LOCK) { + synchronized (TASK_THREAD_LOCK) { + if (isWaiting) { TASK_THREAD_LOCK.notify(); } }