• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ThreadPoolExecutor.DiscardPolicy cannot be resolved

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 75629
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you import it?
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic