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

线程啊_晕了真的好晕
Java code

package com.net;

import javax.swing.SwingUtilities;

public class fdsfsd {
    public static void main(String[] args) {
    }

    public void first() {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {

                Thread thread = new Thread(new Runnable() {
                    public void run() {
                        //我在刷新文件夹呢
                    }
                });
            }
        });
    }

    public void second() {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {

                Thread thread = new Thread(new Runnable() {
                    public void run() {

                    }
                });
            }
        });
    }
}


在first()方法中的"我在刷新文件夹呢",我想让这个刷新动作在1秒后再执行,该怎么写呢,另外下面这段怎么只输出“我显示了”呢?
Java code
import javax.swing.SwingUtilities;

public class fdsfsd {
    public static void main(String[] args) {
        new fdsfsd().first();
    }

    public void first() {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                System.out.println("我显示了");
                Thread thread = new Thread(new Runnable() {
                    public void run() {
                        System.out.println("到里面的run了");
                        try {
                            Thread.sleep(4000);
                        } catch (InterruptedException e) {

                        }
                        System.out.println("我等一会显示");
                        //我在刷新文件夹呢
                    }
                });
            }
        });
    }

}




------解决方案--------------------
LZ真可爱,^_^
------解决方案--------------------

------解决方案--------------------
LZ有意思