Java Reference
In-Depth Information
Another important consideration is defining which exception types to worry
about. Many standard Java statements can actually throw a RuntimeException . As a
matter of standard practice, you should ignore those types of exceptions in your
code. If they happen, something pretty serious is amiss, and your program will ter-
minate with helpful context information, such as the stack trace and what line in
your source code likely caused the error.
However, if you build or use a class that throws a type of IOException , then
those types should be managed in some manner by your program.
E XCEPTION -P ROCESSING S UMMARY
As you can see, Java's implementation of exception processing helps complex sys-
tems manage error conditions in a standard and predictable manner. The require-
ments of good error processing (as defined in the beginning of the chapter)
are encapsulated in the language definition. Classes can define both their return
values and their error conditions. Consumer classes must explicitly define how they
wish to handle these error conditions, either with try...catch code blocks or by
rethrowing the exception. The finally statement ensures that appropriate state-
management functions will be executed, even if exceptions occur. Best of all, the
compiler understands this definition and checks to make sure you are following the
exception-processing rules.
T HREADS
All modern computer operating systems are multitasking systems. A multitasking
system is one that can perform several tasks simultaneously. The operating system
task manager shares computer resources (disk, memory, I/O paths, but especially
the CPU) between the various jobs running on the system. Robust operating sys-
tems are preemptive multitasking systems, meaning that the task manager will
make sure that no single task hogs a resource and causes other tasks to wait.
Historically, an operating system manages its jobs at the process level. Operat-
ing system processes are self-contained execution units (as defined by the operat-
ing system). The operating system creates, schedules, and provides system
resources to processes. Most programming languages (including COBOL and Java)
construct a program that will execute as a process in the host operating system. In-
side that process, there will be memory space managed by the operating system
(kernel space), and memory space that is specific to the process (user space).
 
Search WWH ::




Custom Search