package com
.lzy
.thread
;
public class aStartRun implements Runnable{
@Override
public void run() {
for(int i
=0;i
<20;i
++) {
System
.out
.println("一边studying");
}
}
public static void main(String
[] args
) {
aStartRun sr
=new aStartRun();
Thread t
=new Thread(sr
);
t
.start();
for(int i
=0;i
<20;i
++) {
System
.out
.println("一边play");
}
}
}
28行可代替22-27行代码 前提是所用对象只用一次的情况下,该段代码中的“t”,“sr”对象都是只用了一次
转载请注明原文地址:https://blackberry.8miu.com/read-40417.html