Code example for BlockingQueue

Methods: offer, size

0
    /** Adds a new object to the pool, if possible. 
     * @param t the object to be added 
     * @return if the object was successfully added 
     */ 
    public boolean offer( T t ){
        if ( ( _queue.size() > 0 || _inProgress.get() == _threads.size() ) && 
             _threads.size() < _maxThreads )
            _threads.add( new MyThread() );
        return _queue.offer( t );
    } 
 
    public int inProgress(){ 
	return _inProgress.get();
    } 
 
    public int numThreads(){ 
        return _threads.size();
    } 
 
    class MyThreadGroup extends ThreadGroup {
        MyThreadGroup(){