tph*_*312 2 java multithreading compiler-errors
因此,如果删除import语句,以下非线性的线程示例不会编译.但是,早些时候我没有导入Thread类.有没有人通过这个,请帮助我.
import java.lang.Thread;
class Test {
public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println("current thread is "+t);
t.setName("amar");
System.out.println("after name change "+t);
try {
for(int n=5;n>0;n--) {
System.out.println(n);
Thread.sleep(1000);
}
}catch(InterruptedException e) {
System.out.println("main interrupted");
}
}
}
Run Code Online (Sandbox Code Playgroud)