• Post Reply Bookmark Topic Watch Topic
  • New Topic

Information needed regarding allowCoreThreadTimeOut

 
Allan Kuruvila
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone..

as far as i know, allowCoreThreadTimeOut is available only for Java 6.0 version of ThreadPoolExecutor.
Can anyone tell me how to use the allowCoreThreadTimeOut concept in Java 5.0..

With Regards
Allan
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allan Kuruvila wrote:Hello Everyone..

as far as i know, allowCoreThreadTimeOut is available only for Java 6.0 version of ThreadPoolExecutor.
Can anyone tell me how to use the allowCoreThreadTimeOut concept in Java 5.0..

With Regards
Allan


You have a few options:

1) Upgrade to Java 6.0
2) Write your own implementation that applies the allowCoreThreadTimeOut concept
3) If you set the CorePoolSize to 0, then you will allow all of your Threads to timeout. This has side effects, though. For example, Threads will only be created if the Queue used to hold backed up tasks is full. So if you have a queue of size 100, then 101 tasks must be submitted before a thread gets made. If you have an unbound queue then no threads ever get made. There are work-arounds for this problem (For example, using a SynchronousQueue and a RejectedExecutionHandler to attempt to re-reed tasks to the Executor if the MaxPoolSize is reached). But research all the side effects before using it just to be sure you know what you are getting into.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!