Class DiningApplet
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Panel
-
- java.applet.Applet
-
- ptolemy.domains.csp.demo.DiningPhilosophers.DiningApplet
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.lang.Runnable,javax.accessibility.Accessible,PhilosopherListener
public class DiningApplet extends java.applet.Applet implements java.lang.Runnable, PhilosopherListener
Applet containing Dining Philosophers demo. This demo uses the both the time and conditional communication constructs of the CSP domain in Ptolemy II. It represents the classic concurrency problem, first described by Dijkstra in 1965, which has 5 philosophers sitting around a table with one chopstick between each pair of philosophers. To eat a philosopher must have both chopsticks beside it. Each philosopher thinks for a while, then grabs one chopstick, then the other, eats for a while and puts the chopsticks down. This cycle continues.NOTE: This applet predates much of the infrastructure in Ptolemy II for constructing applets, and also predates swing. It probably should not be used as a model for how to construct applets in Ptolemy II.
- Since:
- Ptolemy II 0.3
- Version:
- $Id$
- Author:
- Neil Smyth
- See Also:
- Serialized Form
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDiningApplet.CurrentTimeThreadclassDiningApplet.EatingRateListenerclassDiningApplet.GoButtonListenerclassDiningApplet.StopButtonListenerclassDiningApplet.ThinkingRateListener-
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
-
-
Field Summary
Fields Modifier and Type Field Description java.awt.Label_currentTimeLabeljava.awt.TextField_eatingRateBoxjava.awt.Button_goButtonCSPDirector_localDirectorManager_managerPhilosopher[]_philosophersjava.awt.Button_stopButtonptolemy.domains.csp.demo.DiningPhilosophers.TablePanel_tablejava.awt.TextField_thinkingRateBoxTypedCompositeActoruniv
-
Constructor Summary
Constructors Constructor Description DiningApplet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinit()Initialize the applet.voidphilosopherChanged()Indicate to the object that implements this interface that the state of a philosopher has changed.voidrun()voidstart()Override the baseclass start method so that the model does not immediately begin executing as soon as the the applet page is displayed.-
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
_currentTimeLabel
public java.awt.Label _currentTimeLabel
-
_goButton
public java.awt.Button _goButton
-
_stopButton
public java.awt.Button _stopButton
-
_eatingRateBox
public java.awt.TextField _eatingRateBox
-
_thinkingRateBox
public java.awt.TextField _thinkingRateBox
-
_table
public ptolemy.domains.csp.demo.DiningPhilosophers.TablePanel _table
-
_philosophers
public Philosopher[] _philosophers
-
univ
public TypedCompositeActor univ
-
_localDirector
public CSPDirector _localDirector
-
_manager
public Manager _manager
-
-
Method Detail
-
init
public void init()
Initialize the applet.- Overrides:
initin classjava.applet.Applet
-
philosopherChanged
public void philosopherChanged()
Description copied from interface:PhilosopherListenerIndicate to the object that implements this interface that the state of a philosopher has changed.- Specified by:
philosopherChangedin interfacePhilosopherListener- See Also:
DiningPhilosophers
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
start
public void start()
Override the baseclass start method so that the model does not immediately begin executing as soon as the the applet page is displayed. Execution begins once the "Go" button is depressed.- Overrides:
startin classjava.applet.Applet
-
-