some fixes for testing in event queue

This commit is contained in:
Mihály Kuprivecz 2017-04-28 12:19:57 +02:00
parent 44401988d1
commit 2830a407ba

View File

@ -52,7 +52,7 @@ public class Audio {
/**
* This method stops the Update Method's thread.
*/
public static void stopService() {
public static synchronized void stopService() {
if (updateThread != null) {
updateThread.interrupt();
}
@ -62,12 +62,13 @@ public class Audio {
* This method stops the Update Method's thread.
* @return boolean
*/
public static boolean isServiceRunning() {
if (updateThread != null) {
return updateThread.isAlive();
}
public static synchronized boolean isServiceRunning() {
if (updateThread != null && updateThread.isAlive() ) {
return true;
} else {
return false;
}
}
/**
* Starts the thread for the Update Method pattern if it was not started previously.
@ -83,6 +84,13 @@ public class Audio {
}
});
}
startThread();
}
/**
* This is a synchronized thread starter
*/
public static synchronized void startThread() {
if (!updateThread.isAlive()) {
updateThread.start();
headIndex = 0;