Skip To Content

Athabasca University

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

  1. use Class.forName to create an object instance without defining its class at the beginning;
  2. develop a multithread application using the Thread class and a runnable interface;
  3. start a thread program using the start() method;
  4. explain the race condition;
  5. use the keyword ‘synchronized’ to solve the issue of concurrent access/updates on shared variables.

Learning Activities

  1. Read the Learning Notes and follow the links to read the recommended online materials.
  2. Read the Review Questions and use the discussion board of this course to
    1. answer any two of the review questions;
    2. share any useful information about the supplemental reading materials that you have read;
    3. comment on another student’s response to the review questions;
    4. answer any questions posed to you.
  3. 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:

  1. Poo, D., Kiong, D., & Ashok, S. (2008). Object-Oriented Programming and Java (2nd ed.). London: Springer-Verlag.
    1. Read Section 11.5: Creating Multiple Threads of Execution (pp. 166–168).
    2. Read Section 11.7: Thread Synchronization and Shared Resources (pp. 169–175).
    3. Read Section 12.2: Rationale Behind Generics (pp. 179–183).
  2. 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.

  3. 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.

  4. Krzyzanowski, P. (2010). Concurrency Control. In Course Notes for CS 417 - Distributed Systems: Concepts and Design. Department of Computer Science, Rutgers University.
  5. 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.

Updated August 05 2020 by FST Course Production Staff