|
From: | Rob Leclerc |
Subject: | Synchronization problem |
Date: | Sat, 17 Mar 2001 00:14:13 -0700 |
I am having some difficulty
synchronizing a certain event. Now from how it appears to me, although I
execute an activity for a certain agent, being that Swarm is a "discrete" agent
simulator, that updating those values are suppose to occur concurrently.
Given this, I am in a situation where one agent moves on top of another agent --
although not on the grid, the agent on the bottom simply has a reference to the
agent. I then have to perform some operations that change the state of the
agent underneath this agent as well, and I then need to compute a new function
that will only executed by the *one* agent on top.
Now as it happens, both agents
end up being on top of one another, since it attempts to execute both activities
for each agent, thus executing both, which is not what I want. What I
attempted to do, was to have a static Hashtable, such that each agent would have
a hashkey based on their name; when they were executing their method, I would
take the object out of the hashtable, and then replace it on the next
activity cycle. And then when in order to execute the method that
needs to be synchronized, I would first inquire whether or not the Hashtable
contained the other agent. I thought this would work since the hashtable
was static, and that one the agent removed itself from the hashtable, that the
other agent would then not be allowed to simultaneously execute the
method.
I also tried to synchronize and
keep the method static, but this had no effect.
Is there any way around this problem?
BTW, thanks for all the help that has been offered
prior to this message.
Rob Leclerc
University of Calgary
|
[Prev in Thread] | Current Thread | [Next in Thread] |