Skip to content

Commit 2830a40

Browse files
committed
some fixes for testing in event queue
1 parent 4440198 commit 2830a40

File tree

1 file changed

+13
-5
lines changed
  • event-queue/src/main/java/com/iluwatar/event/queue

1 file changed

+13
-5
lines changed

event-queue/src/main/java/com/iluwatar/event/queue/Audio.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class Audio {
5252
/**
5353
* This method stops the Update Method's thread.
5454
*/
55-
public static void stopService() {
55+
public static synchronized void stopService() {
5656
if (updateThread != null) {
5757
updateThread.interrupt();
5858
}
@@ -62,11 +62,12 @@ public static void stopService() {
6262
* This method stops the Update Method's thread.
6363
* @return boolean
6464
*/
65-
public static boolean isServiceRunning() {
66-
if (updateThread != null) {
67-
return updateThread.isAlive();
65+
public static synchronized boolean isServiceRunning() {
66+
if (updateThread != null && updateThread.isAlive() ) {
67+
return true;
68+
} else {
69+
return false;
6870
}
69-
return false;
7071
}
7172

7273
/**
@@ -83,6 +84,13 @@ public void run() {
8384
}
8485
});
8586
}
87+
startThread();
88+
}
89+
90+
/**
91+
* This is a synchronized thread starter
92+
*/
93+
public static synchronized void startThread() {
8694
if (!updateThread.isAlive()) {
8795
updateThread.start();
8896
headIndex = 0;

0 commit comments

Comments
 (0)