• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ThreadPoolExecutor.DiscardPolicy cannot be resolved

 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm creating a ThreadPoolExecutor and trying to set the rejection handler. However, Eclipse keeps giving me the error that ThreadPoolExecutor.DiscardPolicy cannot be resolved, even though it autocompletes it.

Am I missing something? I can't figure out a reason that it shouldn't work.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you import it?
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same way I do all of my imports. I let Eclipse autocomplete it.

This resulted in an import statement for ThreadPoolExecutor. I tried adding one for ThreadPoolExecutor.DiscardPolicy, but that didn't do anything.
 
Paul Clapham
Sheriff
Posts: 20990
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it in my Eclipse: I imported ThreadPoolExecutor and put in this line of code:

Eclipse doesn't have a problem with that.
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that worked for me too. But I never thought to try that. And I'm still not sure what it gets me. I was doing the following.



Where q is my queue.
 
Paul Clapham
Sheriff
Posts: 20990
31
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That wouldn't work because you can't pass a type name as a parameter. You need an instance of ThreadPoolExecutor.DiscardPolicy in that position, don't you?
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:That wouldn't work because you can't pass a type name as a parameter. You need an instance of ThreadPoolExecutor.DiscardPolicy in that position, don't you?


Apparently so. When I was originally coding it, I thought DiscardPolicy was just a flag for ThreadPoolExecutor. I didn't realize it was it's own object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic