Unit 5: Type Information and Threads
Unit Overview
This unit will teach you how to design and develop Java programs using Type Information and threads. Run-Time Type Identification (RTTI) allows you to discover type information from an anonymous base-class handle. Thread class and a runnable interface will allow you to develop multithread applications, but it will also force you face the race condition. The keyword ‘synchronized’ will help you deal with concurrent access/updates on shared variables.
Learning Outcomes
After completing this unit, you should be able to
- use Class.forName to create an object instance without defining its class at the beginning;
- develop a multithread application using the Thread class and a runnable interface;
- start a thread program using the start() method;
- explain the race condition;
- use the keyword ‘synchronized’ to solve the issue of concurrent access/updates on shared variables.
Learning Activities
- Read the Learning Notes and follow the links to read the recommended online materials.
- Read the Review Questions and use the discussion board of this course to
- answer any two of the review questions;
- share any useful information about the supplemental reading materials that you have read;
- comment on another student’s response to the review questions;
- answer any questions posed to you.
- Complete the Unit Exercises and share the experience with your peers on the discussion board. [Note: Do not post assignment-relevant pseudocodes or source codes at any time; however, you can post your thoughts, ideas, and problem-solving steps.]
Learning Notes
Read the following recommended online materials:
- Poo, D., Kiong, D., & Ashok, S. (2008). Object-Oriented Programming and Java (2nd ed.). London: Springer-Verlag.
- Read Section 11.5: Creating Multiple Threads of Execution (pp. 166–168).
- Read Section 11.7: Thread Synchronization and Shared Resources (pp. 169–175).
- Read Section 12.2: Rationale Behind Generics (pp. 179–183).
- Eckel, B. (2003). Run-Time Type Identification. Thinking in Java (3rd ed.). Upper Saddle River, NJ: Pearson Education.
This web page belongs to Bruce Eckel’s Thinking in Java.
- Eckel, B. (2003). Passing and Returning Objects. Thinking in Java (3rd ed.) Upper Saddle River, NJ: Pearson Education.
OR
Eckel, B. (2003). Passing & Returning Objects. Thinking in Java (3rd ed.) (Revision 4.0). Upper Saddle River, NJ: Pearson Education.
These web pages belong to Bruce Eckel’s Thinking in Java.
- Krzyzanowski, P. (2010). Concurrency Control. In Course Notes for CS 417 - Distributed Systems: Concepts and Design. Department of Computer Science, Rutgers University.
- Christopher, T. W., & Thiruvathukal, G. K. (2000). Chapter 3: Race Conditions and Mutual Exclusion. In High-Performance Java Platform Computing. Upper Saddle River, NJ: Prentice Hall.