From b57bec0cf8ccab8e39da8376d05ead1f8c625db5 Mon Sep 17 00:00:00 2001 From: jdf Date: Sat, 27 Feb 2010 18:43:31 +0000 Subject: [PATCH] Try to address Mac problem with emulator launch --- .../app/tools/android/EmulatorController.java | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/android/tool/src/processing/app/tools/android/EmulatorController.java b/android/tool/src/processing/app/tools/android/EmulatorController.java index d4e0bfd92..f178accc4 100644 --- a/android/tool/src/processing/app/tools/android/EmulatorController.java +++ b/android/tool/src/processing/app/tools/android/EmulatorController.java @@ -1,22 +1,9 @@ package processing.app.tools.android; import java.io.IOException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; import processing.app.Preferences; -public class EmulatorController { - private static final ExecutorService threads = Executors - .newSingleThreadExecutor(new ThreadFactory() { - public Thread newThread(final Runnable r) { - final Thread t = new Thread(r); - t.setDaemon(true); - t.setName("EmulatorController " + t.getId()); - return t; - } - }); - +class EmulatorController { static void launch() throws IOException { String portString = Preferences.get("android.emulator.port"); if (portString == null) { @@ -39,21 +26,11 @@ public class EmulatorController { final String[] cmd = new String[] { "emulator", "-avd", AVD.ECLAIR.name, "-port", portString, "-netfast", "-no-boot-anim" }; - threads.execute(new Runnable() { - public void run() { - try { - System.err.println("Launching emulator"); - final Process p = Runtime.getRuntime().exec(cmd); - // "emulator: ERROR: the user data image is used by another emulator. aborting" - // make sure that the streams are drained properly - p.getInputStream().close(); - p.getErrorStream().close(); - // new StreamPump(p.getInputStream()).addTarget(System.out).start(); - // new StreamPump(p.getErrorStream()).addTarget(System.err).start(); - } catch (final IOException e) { - e.printStackTrace(System.err); - } - } - }); + System.err.println("Launching emulator"); + final Process p = Runtime.getRuntime().exec(cmd); + // "emulator: ERROR: the user data image is used by another emulator. aborting" + // make sure that the streams are drained properly + new StreamPump(p.getInputStream()).addTarget(System.out).start(); + new StreamPump(p.getErrorStream()).addTarget(System.err).start(); } }