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);
}
}