public class MultiThreadDemo { public static void main(String[] args) { Thread threadA = new Thread(new MyThread()); Thread threadB = new Thread(new MyThread()); threadA.start(); threadB.start(); } } class MyThread implements Runnable { @override public void run() { for (int i = 0; i < 5; i++){ System.out.println("线程:" + Thread.currentThread().getName() + "->" + i); } } }