コード例 #1
0
ファイル: Client.java プロジェクト: fviale/programming
  public static void main(String[] args) {
    String clientName;
    String serverHostName;
    if (args.length < 1) {
      System.out.println("Correct syntax is: client <client name> [server host name]");
      return;
    } else if (args.length == 1) {
      clientName = args[0];
      serverHostName = "";
    } else {
      clientName = args[0];
      serverHostName = args[1];
    }

    try {
      // Creates an active object for the client
      Client theClient =
          org.objectweb.proactive.api.PAActiveObject.newActive(
              Client.class, new Object[] {clientName, serverHostName});
      if (theClient.init()) {
        Thread t = new Thread(new RunClient(theClient));
        t.start();
        t.join();
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
    System.exit(0);
  }
コード例 #2
0
ファイル: Client.java プロジェクト: fviale/programming
 public void run() {
   while (shouldRun) {
     try {
       client.doStuff();
       long l = 500 + (long) (Math.random() * 5000);
       try {
         Thread.sleep(l);
       } catch (InterruptedException e) {
       }
     } catch (Exception e) {
       shouldRun = false;
     }
   }
 }