Sunday, August 14, 2011

How Exception comes while executing the Program..

While execution of many programs we founds exception which stops the program in middle and shows the exact location of problem in code. But normally we are not thinking how this exceptions occur, what the process and who generate this exception....................?
------------------------------​------------------------------​------------------------------​----
So, before going to answer of this question...we should know this:-
------------
Each process has an execution sequence used by the computer CPU. This execution sequence is known as a Thread.
------------
Interrupts:- An interrupt is a mechanism that causes the normal execution flow to branch somewhere else in the computer memory without the knowledge of the execution program.
------------------------------​------------------------------​------------------------------​-----
Now coming to the answer, The exception comes through Threads. while executing the program, threads checks the code and if any error is there it calls the Interrupt handler as shown in the figure, interrupt handler stops the execution in middle and redirect the cursor to exact location of the error in program code.
-----------------------------
This is the brief answer about that, u can check out more related to this.......