我有如下一段代码,在运行java -jar e:\test.jar start后程序开始运行,我现在想要程序退出,我该怎么做?public class ThreadTest extends Thread {
/**
 * @param args
 * @throws dException
 */
private static int i = 0; public static void main(String[] args) throws Exception {
if (args != null && args.length>0) {
String arg = args[0];
if (arg.equals("start")) {
while (true) {
System.out.println("==================" + i);
i++;
sleep(5 * 1000);
}
}else if(arg.equals("quit")){
System.exit(0);
}else{
System.exit(0);
}

} else {
System.exit(0);
}
}}

解决方案 »

  1.   

    好像死循环了啊,把java进程关掉,就退出来了。
      

  2.   

    while (true) {
                        System.out.println("==================" + i);
                        i++;
                        sleep(5 * 1000);
                    }
    你这循环里没有判断退出条件,怎么出?
      

  3.   

    ctrl+c或者编译错误信息提示框的上边有一个按钮,自己找一下。
      

  4.   


    if (args != null && args.length>0) {
                boolean flag = false;
                String arg = args[0];
                if (arg.equals("start")) {
                    flag = true;
                    while (flag ) {
                        System.out.println("==================" + i);
                        i++;
                        sleep(5 * 1000);
                    }
                }else if(arg.equals("quit")){
                    System.exit(0);
                }else{
                    System.exit(0);
                }
                
            } else {
                System.exit(0);
            }
        }
      

  5.   


    这段代码不是死循环,是进入else块里