From 69e691872d1ce57d77fc1c4a307ba4018a07fbd4 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Thu, 17 Nov 2011 23:24:00 +0000 Subject: [PATCH] - simplify multithreading in VideoRecorderAppState git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8714 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/app/state/VideoRecorderAppState.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/engine/src/desktop/com/jme3/app/state/VideoRecorderAppState.java b/engine/src/desktop/com/jme3/app/state/VideoRecorderAppState.java index 1a6f2b3d6..ad8ae4d92 100644 --- a/engine/src/desktop/com/jme3/app/state/VideoRecorderAppState.java +++ b/engine/src/desktop/com/jme3/app/state/VideoRecorderAppState.java @@ -46,15 +46,6 @@ public class VideoRecorderAppState extends AbstractAppState { return th; } }); - private ExecutorService writeThread = Executors.newSingleThreadExecutor(new ThreadFactory() { - - public Thread newThread(Runnable r) { - Thread th = new Thread(r); - th.setName("jME Video Writing Thread"); - th.setDaemon(true); - return th; - } - }); private int numCpus = Runtime.getRuntime().availableProcessors(); public VideoRecorderAppState(File file) { @@ -125,17 +116,11 @@ public class VideoRecorderAppState extends AbstractAppState { Screenshots.convertScreenShot(item.buffer, item.image); item.data = writer.writeImageToBytes(item.image); while (usedItems.peek() != item) { - Thread.sleep(5); + Thread.sleep(1); } - writeThread.submit(new Callable() { - - public Void call() throws Exception { - writer.addImage(item.data); - freeItems.add(item); - return null; - } - }); + writer.addImage(item.data); usedItems.poll(); + freeItems.add(item); return null; } });