public class Demo01Runnable { public static void main(String[] args) { //创建runnable接口的实现对象 RunnableImpl run=new RunnableImpl(); //创建Thread对象,构造方法中传递Runnable接口实现类 Thread t=new Thread(run); //调用start方法开启新线程,执行run方法 t.start(); Runnable r=new Runnable(){ @Override public void run() { System.out.println(Thread.currentThread().getName()+"新线程创建了"); } }; new Thread(r).start(); //简化代码 new Thread(new Runnable(){ @Override public void run() { System.out.println(Thread.currentThread().getName()+"新线程创建了"); } }).start(); } }