日期:2014-05-20  浏览次数:20675 次

大神求解。。为什么我的main方法结束后程序还不停止?
本帖最后由 a85524177 于 2012-11-22 12:54:25 编辑 如代码所示,输入0选择退出后,设置startSort值为false,while(startSort)循环应该结束,main()方法结束,但是在netbean中运行程序仍然不停止。。。奇怪的是调试的时候却会停止。。。小弟不才,有人知道为什么吗???苦恼。。。

public class Main extends JFrame {
    /**
     * @param args the command line arguments
     */
    TextArea ta;                //文本区域组件,用于输入数据
    static File f = new File("data.txt");     //数据文件
    static FileWriter fw;
    static boolean startSort = true;
    
    public static void main(String[] args) {
        // TODO code application logic here
        int param1=0, param2=0;        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            fw = new FileWriter(f);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(args.length==0) {                       //如果命令行没有输入数据
            System.out.println("命令行不含有参数,请选择其他方式导入数据");
            System.out.println("************************************************");
            System.out.println("1.手动输入 2.从文件夹导入 其他:退出");
            System.out.println("************************************************");
            try {
                param1 = Integer.parseInt(br.readLine());
            } catch (IOException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
            if(1==param1) {
                new Main().launchFrame();  //选择手动输入后,弹出数据输入图形界面
            }
            else if(2==param1) {
            }
            else {
                startSort = false;
            }