创建一个多线程,继承“Thread”类
创建一个类,让它继承“Thread”,之后重写一个run方法作为线程体
然后写一个“main”方法。在main方法里
1 //创建一个线程对象 2 TestThreadl testThreadl = new TestThreadl(); 3 //调用start()方法开启线程 4 testThreadl.start();
之后在线程体里做一个for循环,main里也做一个for循环,然后运行,输出结果会两者交互输出。
