package second; public class A extends Thread { public void run(){ for(int i = 1;i <= 10 ; i++){ for(int y=1;y<=i;y++){ System.out.print("*"); } System.out.println(); } } public static void main(String args[]){ A a1 = new A(); A a2 = new A(); A a3 = new A(); a1.start(); a2.start(); a3.start(); } }
PS::如果输出的星星是乱七八糟的,恭喜你,你的多线程实例成功的运行了!