Class 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
      class  DiningApplet.CurrentTimeThread  
      class  DiningApplet.EatingRateListener  
      class  DiningApplet.GoButtonListener  
      class  DiningApplet.StopButtonListener  
      class  DiningApplet.ThinkingRateListener  
      • Nested classes/interfaces inherited from class java.applet.Applet

        java.applet.Applet.AccessibleApplet
      • Nested classes/interfaces inherited from class java.awt.Panel

        java.awt.Panel.AccessibleAWTPanel
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Constructor Summary

      Constructors 
      Constructor Description
      DiningApplet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void init()
      Initialize the applet.
      void philosopherChanged()
      Indicate to the object that implements this interface that the state of a philosopher has changed.
      void run()  
      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.
      • 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.Panel

        addNotify
      • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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
      • _manager

        public Manager _manager
    • Constructor Detail

      • DiningApplet

        public DiningApplet()
    • Method Detail

      • init

        public void init()
        Initialize the applet.
        Overrides:
        init in class java.applet.Applet
      • run

        public void run()
        Specified by:
        run in interface java.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:
        start in class java.applet.Applet