开发者

Java Class - Do not wait for process to exit

开发者 https://www.devze.com 2023-03-21 02:33 出处:网络
I have created a process like so to launch the android emulator: Process p = Runtime.getRuntime().exec(\"emulator.exe -avd Testing -no-boot-anim -scale 0.42\");

I have created a process like so to launch the android emulator:

Process p = Runtime.getRuntime().exec("emulator.exe -avd Testing -no-boot-anim -scale 0.42");

My Java class does what it needs to do but it never ends since that Process has not been destroyed. I just want my Java class 开发者_JAVA百科to do what it needs to do and exit without waiting for or destroying the started process. I've tried:

System.Exit(0)

But my Java class doesn't get pass it. What can I do?


You have to processes the child process' stdout (and stderr) otherwise the call to exec method is blocking. See here Why does Process.waitFor() never return?

0

精彩评论

暂无评论...
验证码 换一张
取 消