1st Edition
Creating Components Object Oriented, Concurrent, and Distributed Computing in Java
Concurrency is a powerful technique for developing efficient and lightning- fast software. For instance, concurrency can be used in common applications such as online order processing to speed processing and ensure transaction reliability. However, mastering concurrency is one of the greatest challenges for both new and veteran programmers. Software developers with all levels of experience can refer to Creating Components: Object Oriented, Concurrent, and Distributed Computing in Java to better understand how concurrency works, more effectively deploy it in program components, and reuse these components to improve program design, quality, and performance.
This text introduces concurrent and component programming to students, engineers, and programmers who are familiar with Java and procedural and GUI programming. It helps them to understand and apply concurrency in Java component programming, while exploring distributed program implementation, Java threads, objects, interfaces, exceptions, component reuse, and system design and management.
By providing the fundamental concepts of object-oriented components and offering templates for distributed program components, this valuable resource reveals how programmers can apply concurrency and components to solve complex problems.
Chapter Goals
What is Concurrent Programming?
Components
Types of Concurrent Programming
THREADS AND PROGRAM CONTEXTS
Writing threads in Java
A Simple Execution Model
Program Safety
Deadlock
DESIGNING AND IMPLEMENTING CONCURRENT PROGRAMS WITH STATE DIAGRAMS
Background
Steps to Create a Concurrent Program
The Producer/Consumer Problem
Why Passive Objects are Components
Gas Station Simulation Problem
Identifiers, Variables, Objects, and Collection Classes
Identifiers and Variables
Java Identifiers and Variables
Primitives
Objects
Collection Classes in Java
PROGRAMMING TO AN INTERFACE
Reuse with Interfaces
Programming to a Promise
Dynamic Polymorphism
Using Multiple Interfaces
Implementing the SortedPrintTable
Using the SortedPrintTable
Expression Trees
EXCEPTIONS IN JAVA
How to Incorrectly Handle Errors
Java Exception Handling
Checked and Unchecked Exceptions
Writing Exceptions
IMPLEMENTING AN ANIMATOR COMPONENT USING THE JAVA EVENT MODEL
A Very Simple Animator
Adding a Speed Control to the Animator
Implementing a Generic Animator
Implementing the Animator using the Java Event Model
Multicasters
COOPERATIVE SYNCHRONIZATION
Cooperative and Competitive Synchronization
Coordinating Threads using Long Sleep Times
Using Wait and Notify to Coordinate Threads
A Solution with a Hidden Race Condition
Solving the Race Condition
Notification Objects
Animating the Gas Station Problem
COMBINING CONCURRENT TECHNIQUES
A First-In-First-Out-Binary-Semaphore
Readers-Writers Problem
An Improved Gas Station Simulation
Improving the Animator
ORGANIZING THE PROBLEM FOR REUSE: REUSE OF UTILITY CLASSES
Types of Reuse
Finding Commonality in Code
Reuse by Copy
Procedural Reuse in Java
Classification: Reuse by Extension
Composition: Reuse by Delegation
Defining the Java Event Model by Extending a Vector
Using Cohesion and Coupling to Evaluate Designs
OBJECT ORIENTED DESIGN
Organizing Objects
Choosing Composition or Classification
Conclusion
PROGRAM MANAGEMENT IN JAVA
What is Program Management?
Implementation Attributes Not Defined in Java
Implementation Attributes Defined in Java
Packages
DISTRIBUTED PROGRAMMING USING RMI
A Brief History of Distributed Computing
Overview of RMI
Implementing a simple program using RMI
Migrating and Non-Migrating Objects
Chat Program
Biography
Charles W. Kann