继承Thread类的方式创建多线程
package MoreThread; public class MoreThread implements Runnable{ @Override public void run() { for(int i = 0;i < 20;i++ ) { System.out.println(); String name = Thread.currentThread().getName(); System.out.println((i+1)+".你好,来自线程"+name); } } } package MoreThread; public class Main { public static void main(String[] args) { MoreThread mt = new MoreThread(); Thread l1 = new Thread(mt); Thread l2 = new Thread(mt); l1.start(); l2.start(); } }