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 Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public class Audio {
52
52
/**
53
53
* This method stops the Update Method's thread.
54
54
*/
55
- public static void stopService () {
55
+ public static synchronized void stopService () {
56
56
if (updateThread != null ) {
57
57
updateThread .interrupt ();
58
58
}
@@ -62,11 +62,12 @@ public static void stopService() {
62
62
* This method stops the Update Method's thread.
63
63
* @return boolean
64
64
*/
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 ;
68
70
}
69
- return false ;
70
71
}
71
72
72
73
/**
@@ -83,6 +84,13 @@ public void run() {
83
84
}
84
85
});
85
86
}
87
+ startThread ();
88
+ }
89
+
90
+ /**
91
+ * This is a synchronized thread starter
92
+ */
93
+ public static synchronized void startThread () {
86
94
if (!updateThread .isAlive ()) {
87
95
updateThread .start ();
88
96
headIndex = 0 ;
You can’t perform that action at this time.
0 commit comments