| | |
| | | return true; |
| | | } |
| | | if (o instanceof DelayList) { |
| | | DelayList<?> other = (DelayList) o; |
| | | DelayList<?> other = (DelayList<?>) o; |
| | | if (other.canEqual(this) && getMaxWait() == other.getMaxWait() && getMaxLen() == other.getMaxLen()) { |
| | | Object this$queue = getQueue(); |
| | | Object other$queue = other.getQueue(); |
| | |
| | | } |
| | | |
| | | public DelayList(int maxWait) { |
| | | this.queue = new ArrayBlockingQueue(100000, true); |
| | | this.queue = new ArrayBlockingQueue<>(100000, true); |
| | | this.maxWait = maxWait; |
| | | this.maxLen = 1000; |
| | | } |
| | | |
| | | public DelayList(int maxWait, int maxLen) { |
| | | this.queue = new ArrayBlockingQueue(100000, true); |
| | | this.queue = new ArrayBlockingQueue<>(100000, true); |
| | | this.maxWait = maxWait; |
| | | this.maxLen = maxLen; |
| | | } |
| | |
| | | if (this.timer == null) { |
| | | System.out.println("创建消费线程"); |
| | | this.timer = new Thread(() -> { |
| | | ArrayList arrayList = new ArrayList(); |
| | | ArrayList<T> arrayList = new ArrayList<>(); |
| | | Queues.drainUninterruptibly(this.queue, arrayList, this.maxLen, this.maxWait, TimeUnit.SECONDS); |
| | | if (arrayList.size() != 0) { |
| | | consumer.accept(arrayList); |