Unit-III
Exception handling and Multithreading
Exception Handling, Fundamentals exception t
uncaught exceptions, throws, throw, try - catch,
built in exceptions, creating your own except
Multithreading Fundamentals, Java Thread mo
priorities, synchronization, messaging, thread c
Runnable interface, Interthread communica
suspending, resuming and stopping threads.
,Java Exception Handling
• Exception Handling is a mechanism to handle exception at runtime.
• Exception is a condition that occurs during program execution and
program termination abnormally.
• There can be several reasons that can lead to exceptions, in
programmer error, hardware failures, files that need to be opened ca
found, resource exhaustion etc.
• Suppose we run a program to read data from a file and if the file
available then the program will stop execution and terminate the prog
reporting the exception message.
• Java exception handling provides a meaningful message to the user ab
issue rather than a system generated message, which may
understandable to a user.
,
, Uncaught Exceptions
Lets understand exception with an example. When we don't han
exceptions, it leads to unexpected program termination. In this prog
ArithmeticException will be throw due to divide by zero.
class UncaughtException Java Exception
{ A Java Exception is an obj
public static void main(String args[]) describes the exception that o
{ a program. When an exc
int a = 0; events occurs in java, an exce
int b = 7/a; // Divide by zero, will said to be thrown. The cod
lead to exception responsible for doing so
} about the exception is
} an exception handler
Exception handling and Multithreading
Exception Handling, Fundamentals exception t
uncaught exceptions, throws, throw, try - catch,
built in exceptions, creating your own except
Multithreading Fundamentals, Java Thread mo
priorities, synchronization, messaging, thread c
Runnable interface, Interthread communica
suspending, resuming and stopping threads.
,Java Exception Handling
• Exception Handling is a mechanism to handle exception at runtime.
• Exception is a condition that occurs during program execution and
program termination abnormally.
• There can be several reasons that can lead to exceptions, in
programmer error, hardware failures, files that need to be opened ca
found, resource exhaustion etc.
• Suppose we run a program to read data from a file and if the file
available then the program will stop execution and terminate the prog
reporting the exception message.
• Java exception handling provides a meaningful message to the user ab
issue rather than a system generated message, which may
understandable to a user.
,
, Uncaught Exceptions
Lets understand exception with an example. When we don't han
exceptions, it leads to unexpected program termination. In this prog
ArithmeticException will be throw due to divide by zero.
class UncaughtException Java Exception
{ A Java Exception is an obj
public static void main(String args[]) describes the exception that o
{ a program. When an exc
int a = 0; events occurs in java, an exce
int b = 7/a; // Divide by zero, will said to be thrown. The cod
lead to exception responsible for doing so
} about the exception is
} an exception handler