我有java监听器。我从客户端收到数据,同时我发回一些代码。下面是我的代码片段,我检查是否有任何待发送的代码发送到设备,如果它将继续尝试发送5次,然后它给出。我注意到,一旦它发送我调用Thread.sleep并导致线程暂停,我无法从客户端接收任何数据,我的所有数据都失败并继续进入循环导致无法确认
for (int i = 0; i < 5; i++) {
// TODO your request here
//Select commandStatus
//check commandStatus if acked then is true else pause and repeat
boolean success = true; // TODO change to whatever outcome of your
// request
if (success) {
break;
}
else {
try {
Thread.sleep(10000l);
}
catch (InterruptedException ie) {
// TODO handle interruptions if applicable
}
}
}