C SC 340 Project 3: Java Consultant Chat Room Simulation
Spring 2009
Due: before lab Tuesday May 12
Worth 15 of your 100 project points

Overview

A Java guru operates an Internet chat room for computer science students ('followers') who wish to discuss the intricacies of Java multithreaded programming. No more than one follower is allowed in the chat room with the guru at any given time. If the chat room is busy, a newly arriving follower will be added to a waiting room of fixed capacity. If the waiting room is full, the follower gives up. Anytime the chat room and waiting room are both empty of followers, the guru takes a nap and must be awakened by the next arriving follower. Your program will simulate the chat room operation using Java threads.

The Cast

Note that each of these will be implemented as a Java class.

Specifications, Details and Requirements

Preliminary: simulation of time
Chat
Guru
WaitingRoom
Follower
Execution trace output

Produce output at selected points to demonstrate that the system works properly.

You will probably need to adjust some of the system parameters to get a nice variety of results. The values given, 10-40 for interarrival and 10-30 for chat, will usually result in very small waiting room populations.
Coordinating threads
Use the Java monitor facilities to coordinate all thread activities.
Generating random values
Documentation

Reproducible Behavior

Follower interarrival times and service (chat room) times are both based on random values. For program testing purposes, you will want to use the same sequence of random values from one run to the next. To achieve this, you need to know a little about how random number generators work.

Random number generators are more accurately called pseudo-random because they are not truly random. Every time the generator is called to generate a number, it calculates the number by applying a formula to its previously-generated number. So how is the first random number generated? It is based on what we call the seed value. If no seed is provided, the default seed is typically based on the computer's clock value. But if you provide a specific seed value, then you control the number sequence. The same sequence will be produced every time you run the program. This is important when testing multi-threaded software because it provides consistency in an otherwise unpredictable testing scenario!

I recommand this technique. Use java.util.Random objects with fixed seed values. Create one Random object to generate interarrival times and a second one to generate service times. Generate the service requirement at the time each follower object is created, and store this value as a follower instance variable. If you follow these recommendations, all random number generation occurs in the same thread (Chat) and both sequences are guaranteed to be reproducible. Be sure to remove the seed for final testing and project submission.

Scoring

The maximum 15 points are broken down as follows:

Extra Credit

For up to 20% (3 points) extra credit, allow as many as N followers to be in the chat room simultaneously. N would be entered as a second run argument.

To Turn In

Send all Java files as email attachments to psanderson@otterbein.edu.


[ C SC 340 | Peter Sanderson | Math Sciences server  | Math Sciences home page | Otterbein ]

Last updated:
Peter Sanderson (PSanderson@otterbein.edu)