final boolean[] received=new boolean[count];
for(int i=0; i < count; i++) {
received[i]=false;
}
final Promise waitingArea=new Promise();
long start=System.currentTimeMillis();
new Thread(new Runnable() {
public void run() {
for(int i=0; i < count; i++) {
Message msg=new Message(null, localAddrOne, new Integer(i));
try {
stub.send(msg, groupName);
if(i % 2000 == 0)
System.out.println("--sent " + i);
}
catch(Exception e) {
waitingArea.setResult(e);
}
}
}
}, "Sending Thread").start();
new Thread(new Runnable() {
public void run() {
int cnt=0;
while(cnt < count) {
try {
Message msg=stub2.receive();
int index=((Integer)msg.getObject()).intValue();
received[index]=true;
cnt++;
if(cnt % 2000 == 0)
System.out.println("-- [stub2] received " + cnt);
}
catch(Exception e) {
waitingArea.setResult(e);
}
}
waitingArea.setResult(Boolean.TRUE);
}
}, "Receiving Thread stub2").start();
new Thread(new Runnable() {
public void run() {
int cnt=0;
while(cnt < count) {
try {
Message msg=stub.receive();
int index=((Integer)msg.getObject()).intValue();
received[index]=true;
cnt++;
if(cnt % 2000 == 0)
System.out.println("-- [stub] received " + cnt);
}
catch(Exception e) {
waitingArea.setResult(e);
}
}
waitingArea.setResult(Boolean.TRUE);
}
}, "Receiving Thread stub").start();
// wait here the stress threads to finish
Object result=waitingArea.getResult((long)timeout * 1000);
long stop=System.currentTimeMillis();
stub2.disconnect();
int messok=0;
for(int i=0; i < count; i++) {