标签:rri 飞机 str stat over star 方式 read tar
public class MyRunnable implements Runnable { @Override public void run() { for (int i=0;i<100;i++){ System.out.println(Thread.currentThread().getName()+": "+i); } } } public class RunnableDemo { public static void main(String[] args) { MyRunnable mr = new MyRunnable(); //Thread(Runnable target) 分配一个新的 Thread对象。 // Thread t1 = new Thread(mr); // Thread t2 = new Thread(mr); //Thread(Runnable target, String name) 分配一个新的 Thread对象 Thread t1 = new Thread(mr,"高铁"); Thread t2 = new Thread(mr,"飞机"); //启动线程 t1.start(); t2.start(); } }
标签:rri 飞机 str stat over star 方式 read tar
原文地址:https://www.cnblogs.com/pxy-1999/p/12793985.html