Esempio n. 1
0
 public RPCSystemProtocol waitforAnswer(UUID uuid) throws InterruptedException {
   DataTogether data = new DataTogether(new CountDownLatch(1));
   map.put(uuid, data);
   if (!data.getLock().await(10, TimeUnit.SECONDS)) {
     throw new InterruptedException();
   }
   return data.getMsg();
 }
Esempio n. 2
0
 public void AnswerReceived(UUID uuid, RPCSystemProtocol msg) {
   while (!map.containsKey(uuid)) {
     try {
       Thread.currentThread().sleep(100);
     } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   DataTogether data = map.get(uuid);
   data.setMsg(msg);
   data.releaseLock();
 }