• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread missed in the middle with ThreadPoolExecutor  RSS feed

Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ppl,

I have a ThreadPoolExecutor, which spawns worker threads to download binaries from an url.

URLDownloadTask is just a runnable URL downloader and print the MD5 of the downloaded file to the log. Now my problem is when I see 200 distinct urls (through the variable i), I see the task count as 200 in line x and 198 or 199 (differs with every execution, but definitely less than 200) at line y. Also only 198 or 199 urls are being downloaded. And I see the missing url's download is initiated and not completed. And as the documentation for .getTaskCount() says

Returns the approximate total number of tasks that have been scheduled for execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.

I am puzzled how can the count decrease in my case. And all the urls are active and I even checked the missing url manually through browser. This occurs with whatever number of urls I mean. For example with 246 distinct urls, I see only 244 or 243 but definitely less than 246.

Please provide your suggestions in this case.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!