Java Reference
In-Depth Information
DAY 7:
Exceptions,
Threads
Today, you complete your weeklong journey through the Java language by
learning about three of its most useful elements: threads, exceptions,
and assertions.
Threads
are objects that implement the
Runnable
interface, which indi-
cates that they can run simultaneously with other parts of a Java pro-
gram.
Exceptions
are objects that represent errors that may occur in a
Java program.
Assertions
are conditional statements and Boolean values
that indicate a program is running correctly, providing another means of
detecting errors.
Threads enable your programs to make more efficient use of resources
by isolating the computing-intensive parts of a program so that they don't
slow down the rest of the program. Exceptions and assertions enable
your programs to recognize errors and respond to them. Exceptions even
assist your programs to correct the conditions if possible.
You start with exceptions because they're one of the things that you use
when working with both assertions and threads.