commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot Hale" <hal...@hotmail.com>
Subject ThreadPool Contribution
Date Mon, 15 Mar 2004 23:44:27 GMT
Hi,

I have been using the Sandbox ThreadPool library, and have been finding it 
quite useful.  I did make a change to the MTQueue.remove() though.  If you 
are interested this is what I changed :

============
MTQueue.java
from 
http://jakarta.apache.org/commons/sandbox/threadpool/xref/org/apache/commons/threadpool/MTQueue.html#113

This way the MTQueue will just wait until something is added to the queue, 
instead of looping every 10 seconds until something is added to the queue.  
the MTQueue.add adequately notifies this Thread and returns null.
============
    /**
     * Removes the first object from the queue.
     * If the Queue is empty, it will wait() until another
     * Runnable is added to the queue.
     */
    public synchronized Object remove(){
        try{
            return list.removeFirst();
        }catch (NoSuchElementException e){
            try {
                wait();
            }
            catch (InterruptedException e1) {
            }
        }
        return null;
    }



Scot Hale

_________________________________________________________________
Get a FREE online computer virus scan from McAfee when you click here. 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message