ABSTRACT
This chapter explains what is happening while a program, either procedural or concurrent, is executing. Once the mystery of how a program works is revealed, the reasons why things happen the way they do should be much clearer. This understanding will be used to show how such mechanisms as
synchronized blocks
and
wait
and
notify
methods can be used to control concurrency in a program. This chapter also introduces the mechanism in Java for creating an
asynchronous activity, the
thread
, and describes how a thread differs from a
process
. This difference will be used to provide an overview of how the current generation of
Web servers
is implemented. Some problems unique to concurrent programming are then identified and solved. These problems involve
safety
(if it finishes, does it get the correct answer?) and
liveness
(does the program finish?) and are affected by the presence or absence of
race conditions
and
deadlock
.