Is there a semantic difference between the terms call stack
and thread stack
, in Java multithreading?
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
.