Package portal.flow.sample.comm

Source Code of portal.flow.sample.comm.ProcessA

package portal.flow.sample.comm;

import java.io.IOException;
import java.net.UnknownHostException;

import portal.flow.sample.comm.bus.Bus;
import portal.util.Logger;

public class ProcessA extends Thread {
 
   private String p0id;
   private Bus bus;
  
   public ProcessA(String p0id) throws UnknownHostException, IOException {
     this.p0id = p0id;   
   }
  
   public void init() {
     try {
        this.bus = new Bus("queue");
       
      } catch (Exception e) {
        e.printStackTrace();
      }
   }
  
   public void run() {
               
      Logger.log("A started!");
      for (int i = 0; i < 10; i++) {
        Logger.log("A waiting("+i+")");
        receive(i, p0id);
     
  }
     
  private void receive(int x, String p0id) {   
      //Portal.exit(pid);
       
        init();
       
      int y = -1;
      try {
        y = (Integer) bus.receive();
      } catch (Exception e) {
        e.printStackTrace();
      }
      Logger.log("A receive("+x+")<-"+y);
  }
}
TOP

Related Classes of portal.flow.sample.comm.ProcessA

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.