public List<JSONObject> take(int maxWaitMillis) throws InterruptedException {
        List<JSONObject> result = new ArrayList<JSONObject>();
        lock.lock();
        try {
            if (samples.size() < batchSize) {
                lessThenBatchSizeCondition.await(maxWaitMillis, TimeUnit.MILLISECONDS);
            }
            if (samples.size() == 0) {
                return result;
            }
            int takedCount = samples.size() < batchSize ? samples.size() : batchSize;
            result.addAll(samples.subList(0, takedCount));
            samples.removeAll(result);
            return result;
        } finally {
            lock.unlock();
        }
    }