创建线程的一种方式:继承Thread类
class Demo extends Thread{//创建线程的第一种方法,继承Thread
public void run(){
for (int i = 0; i < 1000; i++) {
System.out.println("demo run _____"+i);
}
}
}
class ThreadDemo{
public static void main(String[] args) {
Demo d = new Demo();//new出线程对象
d.start();
for (int i = 0; i <1000; i++) {
System.out.println("hello world--"+i);
}
}
}