public class ThreadTest extends Thread { private int count = 10; @Override public void run() { //重写run()方法 while (true) { System.err.print(count + " "); //打印count变量 if (--count == 0) { //count自减,等于0退出循环 return; } } } public static void main(String[] args) { new ThreadTest().start(); }}
Thread方法启动线程
原文地址:https://www.cnblogs.com/gegelaopiaoke/p/10617433.html
时间: 2024-11-05 17:34:06