Threads I: Introduction

Tom Kelliher, CS 245

Oct. 6, 2004

Administrivia

Announcements

Deliverables due today.

Next deliverables due: User interface mock-ups, collaboration diagrams. Due 10/13. Motivation. Don't forget traceability on collaboration diagrams.

Assignment

Complete the lab.

From Last Time

Class design.

Outline

  1. Introduction.

  2. Lab.

Coming Up

Threads II: Synchronization.

Introduction

  1. What is a thread?

  2. Why threads?

  3. How do I make a thread?
    class Foo extends applet
    {
       Bar b = new Bar();
    
       public void init()
       {
          ...
          b.start();  // Get the thread going.
          ...
       }
    }
    
    class Bar extends Thread
    {
       ...
    
       public void run()
       {
          // This is where the thread "lives."
       }
    
    Other thread methods:
    1. sleep()
    2. start()
    3. stop() --- deprecated.

Lab



Thomas P. Kelliher
Tue Oct 5 13:35:50 EDT 2004
Tom Kelliher