我只是想找出为什么这段代码会引发错误。错误是:
“线程“线程 1”java.lang.Error 中的异常”
class Salmon extends Thread
{
public static long id;
public void run()
{
for(int i = 0;i<4; i++){
if(i==2&& id ==Thread.currentThread().getId()){
//if(i==2){
new Thread(new Salmon()).start();
throw new Error();
}
System.out.println(i + " ");
}
}
public static void main(String[] args)
{
Thread t1 = new Salmon();
id = t1.getId();
t1.start();
}
}