1.多线程创建方式1,继承Thread类:
2.多线程创建方式2: 匿名内部类写法
package thread;public class ThreadTest {public static void main(String[] args) {Runnable runnable = new Runnable() {@Overridepublic void run() {for (int i = 0; i < 5; i++) {System.out.println("子线程输出" + i);}}};
//还有两种简化写法,我没写new Thread(runnable).start();for (int i = 0; i < 5; i++) {System.out.println("主线程输出" + i);}}
}