aspose file tools*
The moose likes Java in General and the fly likes ThreadPoolExecutor.DiscardPolicy cannot be resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ThreadPoolExecutor.DiscardPolicy cannot be resolved" Watch "ThreadPoolExecutor.DiscardPolicy cannot be resolved" New topic
Author

ThreadPoolExecutor.DiscardPolicy cannot be resolved

Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
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

Joined: Oct 13, 2005
Posts: 39436
    
  28
How did you import it?
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
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
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

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

Joined: Sep 24, 2008
Posts: 323
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
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

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

Joined: Sep 24, 2008
Posts: 323
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ThreadPoolExecutor.DiscardPolicy cannot be resolved