<分区>
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
循环中添加的大括号)。