【发布时间】:2015-04-20 20:02:04
【问题描述】:
public class MultithreadingFour {
public static void main(String args[]){
A obj = new A();
Task task= new Task();
for(int i=0; i<10; i++)
Thread t= obj.newThread(task);
}
}
编译错误:这一行有多个标记
Syntax error, insert ";" to complete Statement
t cannot be resolved to a variable
Syntax error, insert "AssignmentOperator Expression" to complete Assignment
Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression
Thread cannot be resolved to a variable
而
public class MultithreadingFour {
public static void main(String args[]){
A obj = new A();
Task task= new Task();
for(int i=0; i<10; i++){
Thread t= obj.newThread(task);
}
}
}
编译成功(注意for 循环中添加的花括号)。
【问题讨论】:
-
你到底在问什么?