通过Runnerable创建线程

来源:互联网 发布:网络获客方式 编辑:程序博客网 时间:2024/06/05 05:03
/**
1.创建线程的方法,通过实现接口
*/
public class MyThread implements Runnable{
//设置线程之间的共享的数据
private static int staticcount=1000;
//线程中的实现接口必须实现的接口
public void run(){
System.out.println("new thread");
}
public static void main(String[] args){
//创建线程
Thread th=new Thread(new MyThread());
    //开启线程
th.run();
}


}
原创粉丝点击