• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread pool

 
Murthy Cherukumilli
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello experts,

I have a quetion on the threads. I have designed a thread pool. the thread pool has a behaviour shrink and re-size based on load. And also i have implemented a listener which gets events for pool resize , pool initiate, task started, task completed etc.., Also I have monitor that i have implemented which is monitoring the pool to see if the load is appropriately handled.

Also i want to implement somthing like a timer thread... i.e., i want to stop the thread if the thread doesnot get response in 'x' seconds. But stop is deprecated in the api what is the best way to implement this.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can take a look at Thread.join(long) method. Also ScheduledThreadPoolExecutor in the JDK1.5 may help you.

./pope
 
Henry Wong
author
Sheriff
Posts: 22540
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We actually implemented a thread pool in previous editions of the book. With J2SE 5.0, and the inclusion of a thread pool, we moved it to the appendix. It was kept in the book for two reasons. First, for users of JDK prior to 1.5. And Second, unlike the thread pool executor, it was written to be understood, as a teaching tool, than as a feature laden, optimized class.

Feel free to download it for your purposes. I think it is simple enough that you don't need to buy the book. It is located at http://examples.oreilly.com/jthreads3/. Look in the appendix package for the source for the threadpool class.

Hope this helps,
Henry
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Java theory and practice: Thread pools and work queues describes you about your problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!