• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread Pool with Min,Max. and other thread parameters

 
Priya Vasudevan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
Could you help me find out an implementation of Thread Pool,that keeps track of minimum no. of threads,max. no. of threads in the pool,the increment size of threads,number of idle threads,idle time allowable for a thread,etc...
I also need to know if it is possible to have >5000 threads in a ThreadPool,beacuse I get OutofMemoryError,when I used a ThreadPool( which didn't have any of the above-mentioned parameters!)
Thanks!!!
 
Sumitro Palit
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without trying to answer your question directly, I'd like to point you towards a tremendous resource for multithreaded programming with Java: Concurrent Programming in Java�: Design Principles and Pattern by Doug Lea.
He has a bunch of utilities that will make your life much easier (Check out http://gee.cs.oswego.edu/dl/cpj/).In a nutshell, instead of creating and using Threads yourself you'll use an util class called Executor and pass in your runnable to it. There is a PooledExecutor class which will help you with your problem without having to reinvent the wheel.
BTW, its Doug Lea's work that forms the basis for the enhancements in JDK 1.5 related to threads. I think his utilities were originally based on JDK 1.4, so you should be able to use them - but from 1.5 it will become part of the JDK.
Check out his site and book and draw your own conclusions.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!