package chapter1;
public class Demo2 {
public static void main(String[] args) {
// Runnable runnable = new Runnable() {
// @Override
// public void run() {
// for (int i = 0; i < 100; i++) {
// System.out.println(Thread.currentThread().getName() + i);
// }
// }
// };
//// Thread thread = new Thread("匿名内部类线程");
// Thread thread = new Thread(runnable, "匿名内部类线程");
//// Thread thread = new Thread(runnable);
// thread.start();
Thread thread1 = new Thread() {
@Override
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println(Thread.currentThread().getName() + ": " + i);
}
}
};
thread1.start();
}
}
匿名内部类创建线程
猜你喜欢
转载自blog.csdn.net/qq_43141611/article/details/105638969
今日推荐
周排行