Java Reference
In-Depth Information
goes to the filing cabinet to get the current account balance (assuming
this is an old-fashioned bank that still uses paper files) and gets the
same information. Then the tellers go back to their stations, add in the
deposit, and return to the filing cabinet to record their separately calcu-
lated results. With this procedure, only the last deposit recorded actually
affects the balance. The first modification is lost.
A real bank can handle this problem by having the first teller put a note
into the file that says, "I'm working on this one, wait until I'm finished."
Essentially the same thing is done inside the computer: A lock is associ-
ated with an object to tell when the object is or is not being used.
Many real-world software problems can best be solved by using multiple
threads of control. For example, an interactive program that graphically
displays data often needs to let users change display parameters in real
time. Interactive programs often obtain their best dynamic behavior by
 
Search WWH ::




Custom Search