From 8e76430d07683727f2f62bb04ceb85f335fc5e1a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 10 Jul 2016 22:01:06 +0200 Subject: [PATCH] Revert "Use a dedicated thread pool for audio" --- .../java/mage/client/util/audio/LinePool.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java b/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java index 6f52fdae2d..8145f756bb 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java @@ -5,10 +5,6 @@ import java.util.LinkedList; import java.util.Set; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -23,6 +19,8 @@ import javax.sound.sampled.SourceDataLine; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import mage.utils.ThreadUtils; + public class LinePool { private final Logger log = LoggerFactory.getLogger(getClass()); @@ -43,25 +41,12 @@ public class LinePool { private Mixer mixer; private int alwaysActive; - private ThreadPoolExecutor threadPool; - private int threadCount; public LinePool() { this(new AudioFormat(22050, 16, 1, true, false), 4, 1); } public LinePool(AudioFormat audioFormat, int size, int alwaysActive) { - threadPool = new ThreadPoolExecutor(alwaysActive, size, 30L, TimeUnit.SECONDS, new LinkedBlockingQueue(), new ThreadFactory() { - @Override - public Thread newThread (Runnable runnable) { - threadCount++; - Thread thread = new Thread(runnable, "Audio" + threadCount); - thread.setDaemon(true); - return thread; - } - }); - threadPool.prestartAllCoreThreads(); - format = audioFormat; this.alwaysActive = alwaysActive; mixer = AudioSystem.getMixer(null); @@ -110,7 +95,7 @@ public class LinePool { busyLines.add(line); logLineStats(); } - threadPool.submit(new Runnable() { + ThreadUtils.threadPool.submit(new Runnable() { @Override public void run() {