DZone Forums
Go Back   DZone Forums > Community > Languages & Frameworks > Java
Reload this Page Java Concurrent Programming
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Feb 2008
Location: Belfast, Northern Ireland, UK
Question Java Concurrent Programming - 02-26-2008, 10:56 AM

Hey There,

I’m looking for advice on how to tackle a problem.

The problem is I want to create a simulation of a restaurant scenario using java to code it.

I need to specify the concurrent processes, the sequential activities carried out by each actor and the constructs used to provide mutual exclusion and condition synchronisation.


At the moment this is how I’m thinking of going about tackling it:

• Have one table say with a maximum of 8 seats.

• The actors are the waiter, the customers and reception.

• I need to figure out what each actor should be doing.

• There should be a time limit of some sort for how long customers can be at a table perhaps?

• Some functions/procedures could be wait(), eat(), talk(), order()

• Write classes for the Customer, Waiter, Reception (Booking, Checking In) and Table.

• All classes have to talk to each other in order to run a successful Restaurant simulation.


Am I looking at the problem in the right way or are there other alternative approaches using java that would be better, in trying to simulate this scenario?

Thank You In Advance For Any Advice That Is Offered!

~ Floetic ~
Reply With Quote
  (#2 (permalink)) Old
Member
 
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Feb 2008
Default Some ideas - 02-27-2008, 02:04 AM

Hi, I just wanted to suggest that you may find my recent article that used the Dining Philosophers as a useful starting point for problems such as this.

I think your general approach is the obvious one. Each actor should be run as a thread performing various activities. I would use the java.util.concurrent facilities to handle coordination between actors. You might want to look at CountDownLatch, CyclicBarrier, Semaphore, and the Lock implementations for example.

Another approach is to use asynch message passing over queues, in which case see ExecutorService, LinkedBlockingQueue, etc. Or take a look at actor-based concurrency models as in Scala actors or Erlang.

And another might be to use a tuple spaces approach, such as JavaSpaces. This is an easy approach to shared data but probably a more complicated approach to coordination.

Alex Miller
Pure Danger Tech
Reply With Quote
  (#3 (permalink)) Old
Member
 
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Feb 2008
Location: Belfast, Northern Ireland, UK
Default 02-27-2008, 02:07 PM

Thanx Alex for your suggestions :-) You've given me a better idea of how to go about coding it.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
9th BME International 24-hour Programming Contest challenge24_2009 IT News & Events 0 01-26-2009 09:57 AM
Programming Web Services with SOAP Rivot Ajax & Javascript 0 08-11-2008 09:43 AM
Doubt in java socket programming kanagha Java 2 06-16-2008 06:10 PM
Java Programming Help ogre23 Java 0 04-13-2008 04:13 PM
Programming Help. ogre23 Java 0 04-02-2008 01:13 PM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com