org.kaariboga.agents
Class Counter

java.lang.Object
  |
  +--org.kaariboga.core.Kaariboga
        |
        +--org.kaariboga.agents.Counter
All Implemented Interfaces:
KbMessageHandler, java.lang.Runnable, java.io.Serializable

public class Counter
extends Kaariboga

Demonstrates the handling of time consuming applications by couning up to a given number.

See Also:
Serialized Form

Inner classes inherited from class org.kaariboga.core.Kaariboga
Kaariboga.FireEventThread, Kaariboga.FireMessageThread
 
Field Summary
(package private)  int i
          Count up to i.
(package private)  java.lang.Thread shouldLive
          Used to end the thread.
 
Fields inherited from class org.kaariboga.core.Kaariboga
base, destination, kaaribogaListener, messageListener, name
 
Constructor Summary
Counter(java.lang.String name)
          Creates a new counter that counts up to a given number.
 
Method Summary
 void onDestroy()
          Called by the kaariboga base when this agent has to be destroyed.
 void onDispatch()
          Called by the kaariboga base before the agent is dispatched to another base.
 void run()
          The run method just counts and ends when the thread is set to null.
 
Methods inherited from class org.kaariboga.core.Kaariboga
addKaaribogaListener, addKaaribogaMessageListener, fireDestroyRequest, fireDispatchRequest, fireKaaribogaMessage, fireSleepRequest, getDestination, getName, handleMessage, onArrival, onAwake, onCreate, onSleep, setBase, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

shouldLive

volatile java.lang.Thread shouldLive
Used to end the thread.

i

int i
Count up to i.
Constructor Detail

Counter

public Counter(java.lang.String name)
Creates a new counter that counts up to a given number.
Method Detail

run

public void run()
The run method just counts and ends when the thread is set to null. Transfered to another base it continues counting.
Overrides:
run in class Kaariboga

onDispatch

public void onDispatch()
Called by the kaariboga base before the agent is dispatched to another base. Used here to end the current thread.
Overrides:
onDispatch in class Kaariboga

onDestroy

public void onDestroy()
Called by the kaariboga base when this agent has to be destroyed. Used to end the current thread.
Overrides:
onDestroy in class Kaariboga