fipaos.util
Class MultiThreadedMonitor

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--fipaos.util.Monitor
              |
              +--fipaos.util.MultiThreadedMonitor

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




Fields inherited from class java.lang.Thread
MIN_PRIORITY, NORM_PRIORITY, MAX_PRIORITY

Constructor Summary
MultiThreadedMonitor(Queue queue, int threads)
          Constructor - starts threads running

Method Summary
 synchronized voidaddMonitorListener(MonitorListener ml)
          Adds a MonitorListener to this Monitor
 voidhalt()
          Invoked when this should exit cleanly
 static voidmain(String[] args)
          Test harness for Monitor class
 synchronized voidmonitorUpdate(Object o)
          Deals with incoming objects by dispatching them to our Monitors
 synchronized voidremoveMonitorListener(MonitorListener ml)
          Removes a MonitorListener from this Monitor

Methods inherited from class fipaos.util.Monitor
run

Methods inherited from class java.lang.Thread
currentThread, yield, sleep, sleep, start, stop, stop, interrupt, interrupted, isInterrupted, destroy, isAlive, suspend, resume, setPriority, getPriority, setName, getName, getThreadGroup, activeCount, enumerate, countStackFrames, join, join, join, dumpStack, setDaemon, isDaemon, checkAccess, toString, getContextClassLoader, setContextClassLoader

Methods inherited from class java.lang.Object
getClass, hashCode, equals, 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

addMonitorListener

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

halt

public void halt()
Invoked when this should exit cleanly

main

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

monitorUpdate

public synchronized void monitorUpdate(Object o)
Deals with incoming objects by dispatching them to our Monitors

removeMonitorListener

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

Association Links

to Class java.util.Vector

The Vector containing the targets of the objects

to Class fipaos.util.Monitor

Array of Monitors that belong to this MultiThreadedMonitor

to Class fipaos.util.Queue

Array of queues associated with Monitors