HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / Java / Exception Handling / Java synchronous and asynchronous exceptions

Java synchronous and asynchronous exceptions

In this Java tutorial, learn about asynchronous and synchronous exceptions in Java. Learn how they are different with checked and unchecked exceptions.

1. Asynchronous and synchronous exceptions

Normally Java differentiate the exceptions in two categories on basis of “timing” when they are discovered. These categories are checked and unchecked exceptions.

Similarly, on the basis of place of occurrence, Java exceptions can be divided further in two categories.

  1. Synchronous exceptions
  2. Asynchronous exceptions

2. Synchronous exception

Synchronous exceptions happen at a specific program statement, no matter, how many times we run a program in similar execution environment.

Example of synchronous exceptions are what we care for in our daily life as developer i.e. NullPointerException or ArrayIndexOutOfBoundsException etc.

For example, we run a Java program ‘N’ times with same input. If NullPointerException occur at line number ‘M’ then they will occur at a same line number every time. This is example of synchronous exception in Java.

3. Asynchronous exception

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, or receiving a signal such as “stop” or “suspend” from another thread of execution. For example, if you press ‘CTRL + C’ N times during application execution, no one can guarantee the line number on which the application will end.

I hope that this discussion about Java synchronous and asynchronous exceptions will help you in programming activities as well as Java interviews.

Happy Learning !!

Read More: Oracle Docs

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Reddit

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Feedback, Discussion and Comments

  1. Robin tyagi

    October 2, 2013

    Thanks a lot Lokesh. This discussion was really so much practical and helpful to go in depth of Java programming. Thanks a lot !!

Comments are closed on this article!

Search Tutorials

Java Exceptions

  • try catch finally
  • throw and throws
  • Checked vs Unchecked Exceptions
  • Asynchronous and Synchronous
  • Handle NullPointerException
  • Exception Handling
  • Checked exceptions thrown in initializer blocks can be declared by the constructors

Java Tutorial

  • Java Introduction
  • Java Keywords
  • Java Flow Control
  • Java OOP
  • Java Inner Class
  • Java String
  • Java Enum
  • Java Collections
  • Java ArrayList
  • Java HashMap
  • Java Array
  • Java Sort
  • Java Clone
  • Java Date Time
  • Java Concurrency
  • Java Generics
  • Java Serialization
  • Java Input Output
  • Java New I/O
  • Java Exceptions
  • Java Annotations
  • Java Reflection
  • Java Garbage collection
  • Java JDBC
  • Java Security
  • Java Regex
  • Java Servlets
  • Java XML
  • Java Puzzles
  • Java Examples
  • Java Libraries
  • Java Resources
  • Java 14
  • Java 12
  • Java 11
  • Java 10
  • Java 9
  • Java 8
  • Java 7

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Java 15 New Features
  • Sealed Classes and Interfaces
  • EdDSA (Ed25519 / Ed448)