[Next] [Up] [Previous] [Contents] [Index]
Next: Suspension and attributed variables Up: Timers and time events Previous: Timers and time events   Contents   Index

Example:


[IMAGE png]

The following example shows two agents that behave in accordance with two timers.

go:-
    timer(T1,100), 
    timer(T2,1000),
    ping(T1),
    pong(T2),
    repeat,fail.


ping(T),{time(T)} => write(ping),nl.
pong(T),{time(T)} => write(pong),nl.

[IMAGE png]

Notice that the two calls 'repeat,fail' are needed after the two agents are created. Without them, the query go would succeed before any time event is posted and thus neither of the agent could get a chance to be activated.



Neng-Fa Zhou () 2007-06-05