I have a java code, that should be read by multiple agents, which were created by the JADE platform. Each agent has his own thread of execution. Therefore, all my agents run my java code concurrently, but not simultaneously. I've tried using the Class CyclicBarrier from java API, that should create a barrier in a way that all the agent's threads get together when passing trough this barrier, but this class does not work for agent's threads, just for java threads. Does anybody know a way of synchronizing those agent's threads? Any suggestions?
Asked
Active
Viewed 1,025 times
0

Mike Causer
- 8,196
- 2
- 43
- 63
-
Why do you need agent synchronization? Agents are suppose to work independently. Anyway, you can setup a protocol for that. Here is an example: http://www.db-thueringen.de/servlets/DerivateServlet/Derivate-19681/ESM2009_S337-341.pdf – darlinton Mar 10 '15 at 11:26
2 Answers
0
the fact that Agents in Jade run on a thread and handle their behaviours on that thread means one could utilise CyclicBreaker from the java concurrency packages (java.util.concurrent.CyclicBarrier). Or a more simple form would be the CountDownLatch. But this is in of itself, a OneShotBehaviour implementation.
Sequencing of agent behaviour can be done by using a switch case within each interacting agent behaviour
int state = 0;
switch(state){
state 0:
// Do action one
break;
state 1:
// Do action two
break;
}
state++;

steve_stackex
- 43
- 3
-1
I put a delay in same agents this way:
try{
Thread.sleep(1000); //1000 milliseconds is one second.
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
I hope to help you.
-
1Waiting on a wall clock is *not* a synchronisation mechanism in any way. – JustSid May 05 '15 at 13:33