为什么会出错?

hel*_*esk -1 java multithreading

我只是想知道为什么这段代码会抛出错误.错误是:

"线程中的异常"Thread-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();
      }
}
Run Code Online (Sandbox Code Playgroud)

noo*_*ook 7

因为你告诉它.

 if(i==2){
          new Thread(new Salmon()).start();
          throw new Error(); // <----
Run Code Online (Sandbox Code Playgroud)