1、线程名即为类名,我自己还多此一举写了Thread thread1 =new Thread();
2、继承Thread类
例如打开应用QQ,线程如下实现
import java.awt.Desktop;
import java.io.File;
public class TestFile extends Thread {
private static Desktop desktop;
private String file = "D:/QQ2015/Bin/QQScLauncher.exe";
public static void main(String[] args) {
TestFile test = new TestFile();
test.start();
}
public void run() {
try {
desktop = Desktop.getDesktop();
desktop.open(new File(file));
} catch (Exception e) {
System.out.println("Error!" + e);
}
}
}
效果如下: