5.5 用实现Runable的方式定义线程

来源:互联网 发布:阿里云邮箱账号格式 编辑:程序博客网 时间:2024/06/09 18:22

p { margin-bottom: 0.21cm; }

定义方式

classTestThead implementsRunnable /*extendsThread */{

publicvoidrun() {

intindex = 0;

while(true){

System.out.println("run()"+Thread.currentThread().getName()+index);

index++;

}

}

}

实例化使用方式

ThreadtestThead = newThread(newTestThead());

testThead.start();

原创粉丝点击