Mercurial > hg > FederatedLinda
view src/fdl/test/TestMonitor.java @ 37:2a366abc3f1f
*** empty log message ***
author | kono |
---|---|
date | Sun, 24 Aug 2008 21:21:40 +0900 (2008-08-24) |
parents | fe338d497c72 |
children |
line wrap: on
line source
package fdl.test; import java.net.InetAddress; import java.net.UnknownHostException; import fdl.FDLindaServ; import fdl.FederatedLinda; public class TestMonitor { public FederatedLinda fdl; public FDLindaServ fds; public String localhost; public static final int PORT = 10000; class Server implements Runnable { public void run() { String[] args = {"-p",Integer.toString(PORT)}; System.out.println("Linda server start."); FDLindaServ.main(args); } } class Client implements Runnable { public void run() { String[] args = {}; sleep(4000); System.err.println("Client start."); TestMetaLinda.main(args); } public synchronized void sleep(int time) { try { wait(time); } catch (InterruptedException e) { e.printStackTrace(); } } } class Monitor implements Runnable { public void run() { String[] args = {"-h",localhost,"-p",Integer.toString(PORT)}; sleep(2000); System.err.println("Monitor start."); ComDebug_Client.main(args); } public synchronized void sleep(int time) { try { wait(time); } catch (InterruptedException e) { e.printStackTrace(); } } } public static void main(String[] arg) { TestMonitor me = new TestMonitor(); me.test1(); } public void test1() { try { localhost = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { return; } System.err.println("Monitor Test start."); Server s = new Server(); Client c = new Client(); Monitor m = new Monitor(); Thread ts = new Thread(s); ts.start(); Thread tm = new Thread(m); tm.start(); Thread tc = new Thread(c); tc.start(); try { ts.join(); tm.join(); tc.join(); } catch (InterruptedException e) { } } }