Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    Wouldn't it be better to check if there are any available threads first? This way I would skip hitting database if there are no threads available. Am I missing a point? Commented Jul 17, 2012 at 10:16
  • It depends on which is more likely: Your thread pool running out of threads, or there being no entries in the db waiting to be processed. If in 99.999 of the cases there is nothing in the db, you end up checking your thread pool 99.999 times for nothing, but you are checking the db every single one of the 100.000 times, too (because there are always threads available)! On the other hand, if you have data to process in 99.999 out of 100.000 times, then you should first check for available threads. My point, which I could have stated more clearly, is that Thou Shalt Not Assume. Commented Jul 17, 2012 at 11:16