[mucode-users] mobile agent thread
Brought to you by:
gpietro
|
From: Lukito E. N. <lu...@pa...> - 2000-10-11 11:12:42
|
Dear all,
I modified the mobile agent example of MuCode as follows.
The main program:
public class BounceLauncher {
public static void main(String[] args) {
MuServer s = new MuServer();
new Launcher(s).launch(args, 1);
System.out.println("Spawning the bouncing agent.");
Bouncer b = new Bouncer(args[0], s);
b.start();
}
}
The Bouncer class represents the mobile agent, the code is
as follows.
public class Bouncer extends MuAgent {
String host;
public Bouncer(String host1, MuServer aServer) {
super(aServer);
host = host1;
}
public Bouncer() { super(); }
public void run() {
try {
go(host);
} catch (ClassNotFoundException e) { e.printStackTrace(); }
catch (IOException e) { e.printStackTrace(); }
perform(host);
}
public void perform(String h) {
System.out.println("Bouncer: at " + h);
}
}
I issued 'java mucode.util.Launcher -port 4444' on another terminal,
and run the program with 'java BounceLauncher localhost:4444'.
I expected Bouncer to migrate to the MuServer at localhost:4444,
but this did not happen. The program stops after MuServers have
been activated at port 1968 (default) and 4444.
What is going wrong here ?
Also, when I moved the statement 'perform(host)' before the 'go',
I expected the agent did nothing after migrating to the server
at 4444. What happened was, after the migration, the thread kept
executing the 'perform' call at the remote server (like an
endless loop). Did I miss something ?
Executing 'java -version' gives me this:
java version "1.2.2"
Classic VM (build Linux_JDK_1.2.2_RC4, native threads, sunwjit)
Thanks for help.
Lukito
|