File tree Expand file tree Collapse file tree
event-queue/src/main/java/com/iluwatar/event/queue Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments