protected void waitForMessagesToBeDelivered(){
  long maxWaitTime=60000;
  long waitTime=maxWaitTime;
  long start=(maxWaitTime <= 0) ? 0 : System.currentTimeMillis();
synchronized (lock) {
    while (messages.size() < data.length && waitTime >= 0) {
      try {
        lock.wait(200);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      waitTime=maxWaitTime - (System.currentTimeMillis() - start);
    }
  }
}

protected void waitForMessagesToBeDelivered ( ) { long maxWaitTime = 60000 ; long waitTime = maxWaitTime ; long start = ( maxWaitTime <= 0 ) ? 0 : System . currentTimeMillis ( ) ; synchronized ( lock ) { while ( messages . size ( ) < data . length && waitTime >= 0 ) { try { lock . wait ( 200 ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } waitTime = maxWaitTime - ( System . currentTimeMillis ( ) - start ) ; } } }
waits for messages to be delivered .
