NOTE: These pages had to be reconstructed; please contact the instructor if anything you are looking for seems to be missing. Source code examples taken from the textbook in these slides are available from the publisher. [ Text Web Page ]
NOTE: for the Frenzy project, you will probably not need a separate class
or objects for your controller, but it is a very good idea to use a single
model to represent the state of the game, and have the controller part
of your program invoke model operations that change the game state and update the view.
Discussed processes (program/OS level) vs. threads within a single program.
Communication and switching between threads within a program (e.g. by JVM) has much less overhead than communication
and switching of programs at the OS level.
A priority queue is used to schedule threads for execution by the JVM.
In Java, we
represent multiple threads of execution as objects, each of which
has its own call-stack. The first or `main' thread started by the JVM is indicated
by the main method associated with a class. Other threads are represented
by objects that extend the Thread class or implement the Runnable interface,
and the execution of these threads begins at the run method.
Using Object.wait() and Object.notify()/Object.notifyAll() to:
Release lock in a synchronized block and request lock in future (wait)
Release lock and notify threads waiting on this object lock that the lock is available (notify (1 waiting thread at random), notifyAll (all waiting threads)).