学习java第56天
1.实现Runnable接口
class Run implements Runnable {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println("i =" + i);
}
}
}
启动实现Runnable接口的线程
public class MyRunnable {
public static void main(String[] args) {
MyRunnable.Run run = new MyRunnable().new Run();
Thread t = new Thread(run);
t.start();
}
class Run implements Runnable {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println("i =" + i);
}
}
}
}
2.明天学习内容:线程名字的取得和设置