使用匿名内部类创建线程
生活随笔
收集整理的這篇文章主要介紹了
使用匿名内部类创建线程
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
package com.learn;public class Thread003 {public static void main(String[] args) {System.out.println("main... 主線程開始...");Thread t1 = new Thread(new Runnable() {public void run() {for (int i = 0; i < 10; i++) {System.out.println(" 子 i:" + i);}}});t1.start();for (int i = 0; i < 10; i++) {System.out.println("main..i:" + i);}System.out.println("main... 主線程結(jié)束...");}
}
?
總結(jié)
以上是生活随笔為你收集整理的使用匿名内部类创建线程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 实现runable接口创建线程
- 下一篇: 多线程五种状态