We have read about checked and unchecked exceptions in java many times. Today, I read about new terms in exception handling in java. Perhaps some of you already knew this, but for others, it is worth knowing.
As java differentiate exceptions in two categories on basis of “timing” when they are discovered i.e. checked and unchecked. Similarly, on the basis of place of occurrence, they can be divided in two categories.
- Synchronous exceptions
- Asynchronous exceptions
Synchronous exceptions happen at a specific program statement, no matter, how many times to run a program in similar execution environment.
Example of these exceptions are what we care for in our daily life as developer i.e. NullPointerException or ArrayIndexOutOfBoundsException etc.
If you run a java program n times with same input, they will occur at a same line number every time.
Asynchronous exceptions can raise practically anywhere. It follows that asynchronous exception handling can’t be required by the compiler. They are also difficult to program with.
Examples of naturally asynchronous events include pressing Ctrl-C to interrupt a program, and receiving a signal such as “stop” or “suspend” from another thread of execution.
I hope you liked these new terms as much I enjoyed.
Happy Learning !!