|
Introduction to Concurrent Programming and Components |
|
|
1 | (21) |
|
|
1 | (1) |
|
|
2 | (1) |
|
What Is Concurrent Programming? |
|
|
2 | (10) |
|
Why Do Concurrent Programming? |
|
|
3 | (3) |
|
A Definition of Concurrent Programming |
|
|
6 | (1) |
|
|
7 | (2) |
|
Synchronization of Asynchronous Activities |
|
|
9 | (2) |
|
|
11 | (1) |
|
|
12 | (2) |
|
Types of Concurrent Programming |
|
|
14 | (3) |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
18 | (3) |
|
Threads and Program Contexts |
|
|
21 | (46) |
|
|
21 | (1) |
|
|
22 | (1) |
|
|
22 | (5) |
|
Simple Procedural and Concurrent Programs |
|
|
22 | (2) |
|
|
24 | (1) |
|
Programs with Multiple Threads |
|
|
24 | (3) |
|
|
27 | (15) |
|
A Simple Memory Model (SMM) |
|
|
28 | (1) |
|
Threads, Processes, and Web Servers |
|
|
29 | (3) |
|
Program Execution for a Procedural Program |
|
|
32 | (2) |
|
Program Execution and Context Switching with Threads |
|
|
34 | (5) |
|
|
39 | (1) |
|
Nondeterminism and Concurrency |
|
|
40 | (2) |
|
|
42 | (13) |
|
|
42 | (1) |
|
Race Conditions in Programs |
|
|
43 | (2) |
|
|
45 | (3) |
|
Proving Exhibit 20 (Program2.7b) Is Correct |
|
|
48 | (1) |
|
The Synchronized Modifier |
|
|
49 | (2) |
|
The Wait and Notify/NotifyAll Methods |
|
|
51 | (2) |
|
|
53 | (2) |
|
|
55 | (6) |
|
|
55 | (1) |
|
|
55 | (6) |
|
|
61 | (1) |
|
|
61 | (1) |
|
|
62 | (5) |
|
Designing and Implementing Concurrent Programs with State Diagrams |
|
|
67 | (28) |
|
|
67 | (1) |
|
|
67 | (1) |
|
|
68 | (1) |
|
Steps to Create a Concurrent Program |
|
|
69 | (1) |
|
The Producer/Consumer Problem |
|
|
70 | (9) |
|
|
70 | (1) |
|
Write a Short Description of the Problem |
|
|
70 | (1) |
|
Define the Objects and Relationships |
|
|
70 | (1) |
|
Design and Implement the Active Objects |
|
|
71 | (1) |
|
Design the Passive Object (Components) |
|
|
71 | (3) |
|
Implementing Passive Objects |
|
|
74 | (2) |
|
Implementing the Controlling Object |
|
|
76 | (3) |
|
Why Passive Objects Are Components |
|
|
79 | (1) |
|
Gas Station Simulation Problem |
|
|
80 | (6) |
|
|
80 | (1) |
|
|
80 | (6) |
|
|
86 | (1) |
|
|
86 | (1) |
|
|
87 | (8) |
|
Identifiers, Variables, Objects, and Collection Classes |
|
|
95 | (34) |
|
|
95 | (1) |
|
|
96 | (1) |
|
Identifiers and Variables |
|
|
96 | (3) |
|
Java Identifiers and Variables |
|
|
99 | (1) |
|
|
99 | (1) |
|
|
100 | (15) |
|
Using Runtime Data Type Tags Results in Safer Programs |
|
|
102 | (4) |
|
Memory Allocation is Simpler and Safer |
|
|
106 | (4) |
|
|
110 | (1) |
|
The Serializable Interface |
|
|
110 | (1) |
|
|
111 | (1) |
|
|
112 | (2) |
|
Performance Considerations |
|
|
114 | (1) |
|
Collection Classes in Java |
|
|
115 | (4) |
|
|
115 | (1) |
|
|
116 | (2) |
|
|
118 | (1) |
|
|
119 | (2) |
|
|
121 | (8) |
|
Programming to an Interface |
|
|
129 | (24) |
|
|
129 | (1) |
|
|
130 | (1) |
|
|
130 | (2) |
|
|
132 | (6) |
|
|
132 | (2) |
|
Implementing and Using Promises |
|
|
134 | (3) |
|
|
137 | (1) |
|
|
138 | (1) |
|
Using Multiple Interfaces |
|
|
139 | (2) |
|
Implementing the SortedPrintTable |
|
|
141 | (2) |
|
Using the SortedPrintTable |
|
|
143 | (2) |
|
|
145 | (3) |
|
|
148 | (1) |
|
|
148 | (5) |
|
|
153 | (28) |
|
|
153 | (1) |
|
|
154 | (1) |
|
How to Handle Errors Incorrectly |
|
|
154 | (7) |
|
Handle an Error When It Occurs |
|
|
155 | (4) |
|
|
159 | (2) |
|
|
161 | (6) |
|
|
161 | (4) |
|
Exception Propagation: Unwinding the Stack |
|
|
165 | (2) |
|
|
167 | (1) |
|
Checked and Unchecked Exceptions |
|
|
167 | (5) |
|
|
169 | (2) |
|
Checked and Unchecked Exceptions |
|
|
171 | (1) |
|
|
172 | (3) |
|
Writing the Exception Class |
|
|
173 | (1) |
|
|
174 | (1) |
|
|
174 | (1) |
|
|
175 | (1) |
|
|
176 | (5) |
|
Implementing an Animator Component Using the Java Event Model |
|
|
181 | (50) |
|
|
181 | (1) |
|
|
182 | (1) |
|
|
182 | (7) |
|
|
184 | (2) |
|
|
186 | (3) |
|
Adding a Speed Control to the Animator |
|
|
189 | (4) |
|
Implementing a Generic Animator |
|
|
193 | (17) |
|
The Basic Design of the Animator |
|
|
197 | (4) |
|
Extending the Class Vector |
|
|
201 | (3) |
|
How the Repaint Events Are Generated |
|
|
204 | (1) |
|
Adding the Component Controls |
|
|
205 | (1) |
|
Minimalist Approach to Design |
|
|
206 | (2) |
|
Race Condition in the Generic Animator |
|
|
208 | (2) |
|
Implementing the Animator Using the Java Event Model |
|
|
210 | (5) |
|
|
210 | (3) |
|
Implementing the Corrected Animator Component |
|
|
213 | (2) |
|
|
215 | (7) |
|
|
222 | (5) |
|
|
227 | (4) |
|
Cooperative Synchronization |
|
|
231 | (30) |
|
|
231 | (1) |
|
|
232 | (1) |
|
Cooperative and Competitive Synchronization |
|
|
232 | (3) |
|
Coordinating Threads Using Long Sleep Times |
|
|
235 | (2) |
|
Using Wait and Notify to Coordinate Threads |
|
|
237 | (3) |
|
A Solution with a Hidden Race Condition |
|
|
240 | (3) |
|
Solving the Race Condition |
|
|
243 | (5) |
|
|
248 | (3) |
|
What Are Notification Objects? |
|
|
248 | (1) |
|
Implementing a Notifying Object |
|
|
248 | (3) |
|
Animating the Gas Station Problem |
|
|
251 | (8) |
|
|
259 | (1) |
|
|
259 | (2) |
|
Combining Concurrent Techniques |
|
|
261 | (42) |
|
|
261 | (1) |
|
|
262 | (1) |
|
A First-In/First-Out Binary Semaphore |
|
|
263 | (4) |
|
|
267 | (10) |
|
|
274 | (2) |
|
|
276 | (1) |
|
An Improved Gas Station Simulation |
|
|
277 | (10) |
|
|
283 | (4) |
|
|
287 | (13) |
|
Decoupling the Animator from the Control Panel |
|
|
288 | (4) |
|
Correcting the Repaint Problem |
|
|
292 | (6) |
|
|
298 | (2) |
|
|
300 | (1) |
|
|
301 | (1) |
|
|
301 | (2) |
|
Organizing the Problem for Reuse: Reuse of Utility Classes |
|
|
303 | (30) |
|
|
303 | (1) |
|
|
304 | (1) |
|
|
304 | (3) |
|
Finding Commonality in Code |
|
|
307 | (1) |
|
|
307 | (3) |
|
|
310 | (6) |
|
Classification: Reuse by Extension |
|
|
316 | (4) |
|
Composition: Reuse by Delegation |
|
|
320 | (5) |
|
Defining the Java Event Model by Extending a Vector |
|
|
325 | (4) |
|
Using Cohesion and Coupling to Evaluate Designs |
|
|
329 | (2) |
|
|
331 | (1) |
|
|
332 | (1) |
|
|
332 | (1) |
|
|
333 | (34) |
|
|
333 | (1) |
|
|
334 | (1) |
|
|
334 | (13) |
|
Composition: ``Has-a'' Relationships |
|
|
335 | (3) |
|
|
338 | (1) |
|
|
339 | (1) |
|
Using Aggregation and Association |
|
|
340 | (1) |
|
Classification: ``Is-a'' Relationships |
|
|
341 | (1) |
|
Abstract Classes versus Interfaces |
|
|
341 | (3) |
|
Using Classification to Mimic Composition |
|
|
344 | (3) |
|
Choosing Composition or Classification |
|
|
347 | (10) |
|
Check to Ensure That the Relationship Is an ``Is-a'' Relationship |
|
|
347 | (1) |
|
Be Sure the Object Type Is Not Mutable |
|
|
348 | (3) |
|
Check If the Type Simply Represents a Role |
|
|
351 | (1) |
|
Check for Subclasses with Multiple Roles |
|
|
352 | (2) |
|
Check for Compatibility with the Program Implementation |
|
|
354 | (3) |
|
|
357 | (3) |
|
|
360 | (1) |
|
|
360 | (7) |
|
Program Management in Java |
|
|
367 | (18) |
|
|
367 | (1) |
|
|
368 | (1) |
|
What Is Program Management? |
|
|
368 | (2) |
|
Implementation Attributes Not Defined in Java |
|
|
370 | (3) |
|
|
370 | (1) |
|
|
371 | (1) |
|
|
372 | (1) |
|
Interactive Development Environment (IDE) |
|
|
373 | (1) |
|
|
373 | (1) |
|
Implementation Attributes Defined in Java |
|
|
373 | (6) |
|
|
373 | (2) |
|
|
375 | (1) |
|
|
375 | (1) |
|
Final Classes and Methods |
|
|
376 | (1) |
|
|
376 | (2) |
|
|
378 | (1) |
|
|
379 | (4) |
|
|
379 | (1) |
|
Scope Resolution Modifiers |
|
|
380 | (1) |
|
Distributing Source Programs |
|
|
380 | (3) |
|
|
383 | (2) |
|
Distributed Programming Using RMI |
|
|
385 | (24) |
|
|
385 | (1) |
|
|
386 | (1) |
|
A Brief History of Distributed Computing |
|
|
386 | (1) |
|
|
387 | (3) |
|
Implementing a Simple Program Using RMI |
|
|
390 | (1) |
|
Implement the RMI Interface |
|
|
390 | (6) |
|
Implement the RMI Server Class |
|
|
391 | (1) |
|
Implement the RMI Client Class |
|
|
392 | (2) |
|
Creating and Distributing the Skeleton and Stub Files |
|
|
394 | (1) |
|
Distributing and Running the Program |
|
|
395 | (1) |
|
Migrating and Non-Migrating Objects |
|
|
396 | (4) |
|
|
400 | (6) |
|
|
400 | (3) |
|
|
403 | (3) |
|
|
406 | (1) |
|
|
406 | (1) |
|
|
406 | (3) |
Appendix A Key Words |
|
409 | (6) |
References |
|
415 | (4) |
Index |
|
419 | |