0

I have to write a program in Java that takes flight data from a CSV file and simulates the flight; that is, use a thread to change the state of each flight. Here's a more specific description from the project page:

Write a program that manages information flow regarding flight status across many airlines and airports. The airline monitor, the event generator and the airport status monitors will be initialized with the daily flight schedule using provided CSV file. The schedule covers flights that depart during the busiest hour of the day 4-5pm.

Now, here's a description of all the threads I have to implement:

Airline Monitor threads: starts a thread for each airline to receive and publish changes to the threads represented by the departure and arrival cities involved. For example, if flight 244 from BHM to DCA is delayed, publish the delay to the BHM and DCA flight status monitors.

Airport Flight Status Monitor threads: starts a thread for each airport and monitors all flights at that airport. Each airport receives events on flights from each airline as they are generated. Each thread will publish the current flight status for the airport to an arrival and departure file.

Flight Event Generator thread: starts a single thread to generate changes to flights, including delays, boarding, left gate, take off, landed, and at gate.

My question is simple in nature. I'm struggling to find a good starting point and structure for the program. Should it just be one main file with threads weaving throughout? Or should I implement an object-oriented structure, with classes for each type of thread?

Finally, obviously this is a convoluted instance of the producer-consumer problem. I've chosen to use a circular buffer to store the flight information that needs to be passed between threads. Would it be possible to give an example of how a circular buffer is implemented for this type of problem (but not this problem specifically)? Thanks!

EDIT: I don't have to design the whole airport system; this is specifically a multithreading project. Consider the following line from the CSV file:

1,sw,mdw,mco,1600,:50

This specifies that this is the first flight of the day, on Southwest Airlines, from Chicago Midway to Orlando, taking off at 1600 hours (4:00 PM), with a flight time of 50 minutes. I don't need classes Airport and Flight; these are simulated by these data from the CSV. I'm just not sure what to do with the 'southwest' airline thread, the 'mdw' and 'mco' airport threads, and the flight event generator thread, and how they should interact.

aquemini
  • 950
  • 2
  • 13
  • 32
  • 2
    It's not remotely simple. It's a major design effort, for which you have provided only a skimpy specification. Forget the threads, start with designing classes for Airport, Flight etc. – Martin James Feb 21 '13 at 16:07
  • Edited to demonstrate why the design isn't as large-scale as it seemed. I don't have to manipulate anything with flights and airports, just monitor and publish them with threads. – aquemini Feb 21 '13 at 17:05

1 Answers1

0

Take a look at the docs. You'll find all the API components related to concurrence there: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html

For reading the file, I'd suggest using channels: http://docs.oracle.com/javase/7/docs/api/index.html?java/util/concurrent/package-summary.html

Alberto Segura
  • 755
  • 1
  • 12
  • 28