Example usage for java.util LinkedList removeIf

List of usage examples for java.util LinkedList removeIf

Introduction

In this page you can find the example usage for java.util LinkedList removeIf.

Prototype

default boolean removeIf(Predicate<? super E> filter) 

Source Link

Document

Removes all of the elements of this collection that satisfy the given predicate.

Usage

From source file:org.hyperledger.fabric.sdk.Channel.java

void runSweeper() {

    if (shutdown || DELTA_SWEEP < 1) {
        return;//  w  ww  . java 2  s .c om
    }

    if (sweeper == null) {

        sweeperExecutorService = Executors.newSingleThreadScheduledExecutor(r -> {
            Thread t = Executors.defaultThreadFactory().newThread(r);
            t.setDaemon(true);
            return t;
        });
        sweeper = sweeperExecutorService.scheduleAtFixedRate(() -> {
            try {

                if (txListeners != null) {

                    synchronized (txListeners) {

                        for (Iterator<Map.Entry<String, LinkedList<TL>>> it = txListeners.entrySet()
                                .iterator(); it.hasNext();) {

                            Map.Entry<String, LinkedList<TL>> es = it.next();

                            LinkedList<TL> tlLinkedList = es.getValue();
                            tlLinkedList.removeIf(TL::sweepMe);
                            if (tlLinkedList.isEmpty()) {
                                it.remove();
                            }
                        }
                    }
                }
            } catch (Exception e) {
                logger.warn("Sweeper got error:" + e.getMessage(), e);
            }

        }, 0, DELTA_SWEEP, TimeUnit.MILLISECONDS);
    }

}