Hi Attila,

You have made some good points, included you will find a new evictor implementation with the enhancements you proposed. I didn't want to use interrupt() so I used a wait/notify technique with synchronized blocks.

Can you try this version and let me know if it works for you?

Cheers
Dirk

=================================================================

    class Evictor implements Runnable {
        private boolean _cancelled = false;
        private long _delay = 0L;

        public Evictor(long delay) {
            _delay = delay;
        }

        synchronized void cancel() {
            _cancelled = true;
            notifyAll();
        }

        synchronized boolean isCancelled() {
                return _cancelled;
        }

        private synchronized void sleep() {
                if (_delay > 0) {
                        long now = System.currentTimeMillis();
                        long wakeup = now + _delay;
                        while (!isCancelled() && (now < wakeup)) {
                                try {
                                                wait(wakeup - now);
                                        } catch (InterruptedException e) {
                            // ignored
                                        }
                                        now = System.currentTimeMillis();
                        }
                }
        }

        public void run() {
                sleep();
            while(!isCancelled()) {
                try {
                    evict();
                } catch(Exception e) {
                    // ignored
                }
                try {
                    ensureMinIdle();
                } catch(Exception e) {
                    // ignored
                }
                sleep();
            }
            synchronized(GenericObjectPool.this) {
                if(null != _evictionCursor) {
                    _evictionCursor.close();
                    _evictionCursor = null;
                }
            }
        }

    }


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to