kill the zombies
This commit is contained in:
parent
5cf8befdc1
commit
60e6ed1277
|
@ -1,8 +1,10 @@
|
|||
import javazoom.jl.decoder.JavaLayerException;
|
||||
import javazoom.jl.player.Player;
|
||||
|
||||
import java.awt.List;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -10,6 +12,8 @@ public class SoundHandler {
|
|||
|
||||
private static boolean soundOn = true;
|
||||
|
||||
private static ArrayList<Thread> runningThreads = new ArrayList<Thread>();
|
||||
|
||||
// Wenn fehler beim erstellen von .jar mit sound hier gucken
|
||||
private static HashMap<String, String> sounds = new HashMap<String, String>(Map.of(
|
||||
"hit", "./Sound/water-drip.mp3"
|
||||
|
@ -17,7 +21,7 @@ public class SoundHandler {
|
|||
|
||||
public static void playSound(String soundName) {
|
||||
if (soundOn) {
|
||||
new Thread(new Runnable() {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -27,9 +31,23 @@ public class SoundHandler {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
// TODO: kill zombies
|
||||
});
|
||||
thread.start();
|
||||
runningThreads.add(thread);
|
||||
}
|
||||
for (Thread oldThread : runningThreads) {
|
||||
if (!oldThread.isAlive()) {
|
||||
|
||||
try {
|
||||
oldThread.join();
|
||||
runningThreads.remove(oldThread);
|
||||
System.out.println("cleared thread");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue