Difference between “call stack” and “thread stack”

前端 未结 4 1641
粉色の甜心
粉色の甜心 2021-02-01 08:42

Is there a semantic difference between the terms call stack and thread stack, in Java multithreading?

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 09:37

    When FileWriter throws an IOException, the runtime system immediately stops executing the try block; method calls being executed are not completed. The runtime system then starts searching at the top of the method call stack for an appropriate exception handler.
    In this example, when the IOException occurs, the FileWriter constructor is at the top of the call stack. However, the FileWriter constructor doesn't have an appropriate exception handler, so the runtime system checks the next method — the writeList method — in the method call stack. The writeList method has two exception handlers: one for IOException and one for IndexOutOfBoundsException.

提交回复
热议问题