package com.heima.Thread;
public class Demo2_Thread {
/**
* @param args
*/
public static void main(String[] args) {
MyRunnable mr = new MyRunnable(); //4.创建Runnable的子类对象
Thread mt = new Thread(mr); // 5 将其当做参数传递给Thread的构造函数
mt.start(); // 6.开启线程
for(int i=0 ; i < 1000; i++ ){
System.out.println("bb");
}
}
}
class MyRunnable implements Runnable { //1.定义一个Runnable方法
public void run() { // 2.重写run方法
for(int i= 0 ; i < 1000; i++ ) { // 3.将要执行的代码写到run方法
System.out.println("aaaaaaaaaaaaaa");
}
}
}