Code example for ConcurrentLinkedQueue

Methods: offer

0
    public void put(Selector s) throws IOException {
        if ( SHARED ) return;
        if ( enabled ) active.decrementAndGet();
        if ( enabled && (maxSpareSelectors==-1 || spare.get() < Math.min(maxSpareSelectors,maxSelectors)) ) {
            spare.incrementAndGet();
            selectors.offer(s);
        } 
        else s.close();
    } 
 
    public void close() throws IOException { 
        enabled = false;
        Selector s;
        while ( (s = selectors.poll()) != null ) s.close();
        spare.set(0);
        active.set(0);
        if (blockingSelector!=null) {
            blockingSelector.close();
        } 
        if ( SHARED && getSharedSelector()!=null ) {
Stop searching for code, let great code find you!  Add Codota to your java IDE