File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed
queue-based-load-leveling/src/main/java/com/iluwatar/queue/load/leveling
server-session/src/main/java/com/iluwatar/sessionserver
twin/src/main/java/com/iluwatar/twin Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 3636public class MessageQueue {
3737
3838 private final BlockingQueue <Message > blkQueue ;
39- public final Object serviceExecutorWait = new Object ();
39+ public Object serviceExecutorWait =new Object ();
4040
4141 // Default constructor when called creates Blocking Queue object.
4242 public MessageQueue () {
@@ -51,7 +51,9 @@ public void submitMsg(Message msg) {
5151 try {
5252 if (null != msg ) {
5353 blkQueue .add (msg );
54- serviceExecutorWait .notify ();
54+ synchronized (serviceExecutorWait ) {
55+ serviceExecutorWait .notifyAll ();
56+ }
5557 }
5658 } catch (Exception e ) {
5759 LOGGER .error (e .getMessage ());
Original file line number Diff line number Diff line change @@ -56,8 +56,8 @@ public class App {
5656
5757 // Map to store session data (simulated using a HashMap)
5858
59- private static Map <String , Integer > sessions = new HashMap <String , Integer >();
60- private static Map <String , Instant > sessionCreationTimes = new HashMap <String , Instant >();
59+ private static Map <String , Integer > sessions = new HashMap <>();
60+ private static Map <String , Instant > sessionCreationTimes = new HashMap <>();
6161 private static final long SESSION_EXPIRATION_TIME = 10000 ;
6262 private static final Object sessionExpirationWait = new Object (); // used to make expiration task wait or work based on event (login request sent or not)
6363
@@ -125,7 +125,7 @@ private static void sessionExpirationTask() {
125125 */
126126 public static void expirationTaskWake () {
127127 synchronized (sessionExpirationWait ) {
128- sessionExpirationWait .notify ();
128+ sessionExpirationWait .notifyAll ();
129129 }
130130 }
131131
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ public void resumeMe() {
8686 LOGGER .info ("Begin to resume BallThread" );
8787
8888 synchronized (lock ) {
89- lock .notify ();
89+ lock .notifyAll ();
9090 }
9191 }
9292
@@ -97,7 +97,7 @@ public void stopMe() {
9797 this .isRunning = false ;
9898 this .isSuspended = true ;
9999 synchronized (lock ) {
100- lock .notify ();
100+ lock .notifyAll ();
101101 }
102102 }
103103}
You can’t perform that action at this time.
0 commit comments