当前位置: 代码迷 >> J2SE >> 用java能够列出当前运行的进程么解决方案
  详细解决方案

用java能够列出当前运行的进程么解决方案

热度:213   发布时间:2016-04-24 17:53:25.0
用java能够列出当前运行的进程么
rt

------解决方案--------------------
public class Test implements Runnable
{
public void go()
{
new Thread(this).start();
}

public static void main(String[] args)
{
System.out.println( "main= "+Thread.currentThread());
new Test().go();
System.out.println( "main= "+Thread.currentThread());
}

public void run()
{
System.out.println( "run= "+Thread.currentThread());
}
}

------解决方案--------------------
楼上的答非所问
问进程,不是线程
------解决方案--------------------
JAVA实现不了,到最后还是调用系统命令
WIN用tasklist
Linux 下用
Runtime rt = Runtime.getRuntime();
Process process = rt.exec( "ps -ax ");
这样写其实没社么意义了已经.

------解决方案--------------------
顶一下楼上的,不过这也是java的runtime的一个应用了
  相关解决方案