fipaos.util
Class MultiThreadedMonitor

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--fipaos.util.Monitor
              |
              +--fipaos.util.MultiThreadedMonitor
All Implemented Interfaces:
MonitorListener, java.lang.Runnable

public class MultiThreadedMonitor
extends Monitor
implements MonitorListener

This is an extension of the Monitor object. When an object is placed into the queue it is passed to all of the MonitorListener registered with this MultiThreadedMonitor. WARNING: There is no guarantee that objects will arrive at the MonitorListener's in the order they are placed into the Queue this MultiThreadedMonitor is observing. It is possible that more than one thread will invoke the monitorUpdate() method at a time, so the implementation should be thread-safe.

See Also:
fipaos.util.Monitor


Inner classes inherited from class fipaos.util.Monitor
Monitor.MonitorListenerTest
 
Fields inherited from class fipaos.util.Monitor
_target
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MultiThreadedMonitor(Queue queue, int threads)
          Constructor - starts threads running
 
Method Summary
 void addMonitorListener(MonitorListener ml)
          Adds a MonitorListener to this Monitor
 void halt()
          Invoked when this should exit cleanly
static void main(java.lang.String[] args)
          Test harness for Monitor class
 void monitorUpdate(java.lang.Object o)
          Deals with incoming objects by dispatching them to our Monitors
 void removeMonitorListener(MonitorListener ml)
          Removes a MonitorListener from this Monitor
 
Methods inherited from class fipaos.util.Monitor
run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiThreadedMonitor

public MultiThreadedMonitor(Queue queue,
                            int threads)
Constructor - starts threads running
Parameters:
queue - The queue that should be used for buffering waiting objects
threads - The number of threads to be used (NOTE: These may push objects to the MonitorListener's registered concurrenty.
Method Detail

monitorUpdate

public void monitorUpdate(java.lang.Object o)
Deals with incoming objects by dispatching them to our Monitors
Specified by:
monitorUpdate in interface MonitorListener

addMonitorListener

public void addMonitorListener(MonitorListener ml)
Adds a MonitorListener to this Monitor
Parameters:
The - MonitorListener to add

removeMonitorListener

public void removeMonitorListener(MonitorListener ml)
Removes a MonitorListener from this Monitor
Parameters:
The - MonitorListener to remove

halt

public void halt()
Invoked when this should exit cleanly
Overrides:
halt in class Monitor

main

public static void main(java.lang.String[] args)
Test harness for Monitor class