This post originated from an RSS feed registered with Java Buzz
by Nick Lothian.
Original Post: java.util.concurrent.Executors
Feed Title: BadMagicNumber
Feed URL: http://feeds.feedburner.com/Badmagicnumber
Feed Description: Java, Development and Me
I think java.util.concurrent.Executors (and related functionality like Futures) is one of the best features of JDK 1.5.
One small feature I'd like, though - a newCachedThreadPool(int nThreads) factory method that combines the features of newCachedThreadPool() and newFixedThreadPool(int nThreads). It would create a thread pool that creates new threads as needed up to the number specified by nThreads reusing previously constructed threads when they are available.
This functionality is available directly in java.util.concurrent.ThreadPoolExecutor, but a factory method would be delightful. Surely I'm not the only person who would find a thread pool with a max limit on size that shrinks after use more useful than either a FixedThreadPool or an unbound CachedThreadPool?