public void run() {
            Runnable job = null;                  

            while (true) {
                while (true) {
                    synchronized (_lock) {
                        // Keep processing jobs until none availble
                        if (_pendingJobs.size() == 0) {
                            cat.debug("Idle Thread...");

                            ThreadElement elem = _busyThreads.remove();
                            if (elem == null) {
                                return;
                            }

                            elem._idle = true;
                            _idleThreads.add(elem);
                            break;
                        }

                        // Remove a job from the pending list.
                        job = (Runnable)_pendingJobs.remove(_pendingJobs.size()-1);                                          
                    }               

                    // run the job
                    job.run();
                    job = null;
                }            

                try {
                    synchronized (this) {
                        // if no idle time specified, 
                        // wait till notified.
                        if (_maxIdleTime == -1) {
                            wait();
                        } else {
                            wait(_maxIdleTime);
                        }
                    }                        
                } catch( InterruptedException e ) {
                    // Cleanup if interrupted
                    synchronized (_lock) {
                        cat.debug("Interrupted...");
                        _idleThreads.remove();
                    }
                    return;
                }

                // Just been notified or the wait timed out
                synchronized(_lock) {
                    // If there are no jobs, that means we "idled" out.
                    if (_pendingJobs.size() == 0) {
                        if (_minThreads != -1 && totalThreads() > _minThreads) {
                            cat.debug("Thread timed out...");
                            _idleThreads.remove();
                            return;    
                        }
                    }
                }
            }
        }