Java多线程
实现多线程有两种方式,第一种方式,实现runnable接口,第二种方式,继承thread类
重写run方法
public class Runnable1 implements runnable{
public void run(){
for(int i=0;i<5;i++){
System.out.printLn("Thread"+i);
}
}
}
public class Test{
Runnable1 run1 = new Runnable1();
Thread t1 = new Thread(run1);
Thread t2 = new Thread(run1);
t1.start();
}