@Override
        public final void run() {
            try {

                long deadlineMs = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS)
                        + config.getMaxBatchOpenMs() + 1;
                long t = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);

                List<R> requests;
                List<QueueBufferFuture<R, Result>> futures;

                synchronized (this) {
                    while (!closed && (t < deadlineMs)) {
                        t = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);

                        // zero means "wait forever", can't have that.
                        long toWait = Math.max(1, deadlineMs - t);
                        wait(toWait);
                    }

                    closed = true;

                    requests = new ArrayList<R>(this.requests);
                    futures = new ArrayList<QueueBufferFuture<R, Result>>(this.futures);
                }

                process(requests, futures);

            } catch (InterruptedException e) {
                failAll(e);
            } catch (AmazonClientException e) {
                failAll(e);
            } catch (RuntimeException e) {
                failAll(e);
                throw e;
            } catch (Error e) {
                failAll(new AmazonClientException("Error encountered", e));
                throw e;
            } finally {
                // make a copy of the listener since it (theoretically) can be
                // modified from the outside.
                Listener<OutboundBatchTask<R, Result>> listener = onCompleted;
                if (listener != null) {
                    listener.invoke(this);
                }
            }
        }
Processes the batch once closed. Is <em>NOT</em> called with a lock on {@code this}.
However, it's passed a local copy of both the {@code requests} and {@code futures} lists
made while holding the lock.
aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/SendQueueBuffer.java