while (reqHdl.getLastExchange() == null) {
QAUtil.sleep(100);
}
final AtomicBoolean isAllDataSend = new AtomicBoolean();
final IHttpExchange serverExchange = reqHdl.getLastExchange();
System.out.println("[" + (System.currentTimeMillis() - startTime) + "] server: suspend receiving");
serverExchange.getConnection().suspendReceiving();
Runnable resumeTask = new Runnable() {
public void run() {
QAUtil.sleep(1500);
if (isAllDataSend.get()) {
isErrorOccured.set(true);
}
try {
System.out.println("[" + (System.currentTimeMillis() - startTime) + "] server: resume receving");
serverExchange.getConnection().resumeReceiving();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
};
new Thread(resumeTask).start();
System.out.println("[" + (System.currentTimeMillis() - startTime) + "] client: start sending...");
for (int i = 0; i < 100; i++) {
dataSink.write(QAUtil.generateByteArray(1000));
}
isAllDataSend.set(true);
System.out.println("[" + (System.currentTimeMillis() - startTime) + "] client: finished sending");
QAUtil.sleep(2500);