線程練習2-4
package sample1; public class ThreadPrint { class ThreadPrinter extends Thread{ @Override public void run(){ for (int i = 1; i <= 10 ; i++) { System.out.println(this.getName() + " is printing " + i); } } } public void start(){ ThreadPrinter printerThread = new ThreadPrinter(); printerThread.setName("Printer"); printerThread.start(); } public static void main(String[] args) { new ThreadPrint().start(); } }
9
收起
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星