Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 647391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:43:02+00:00 2026-05-13T21:43:02+00:00

PriorityBlockingQueue is unbounded, but I need to bound it somehow. What is the best

  • 0

PriorityBlockingQueue is unbounded, but I need to bound it somehow. What is the best way to achieve that?

For information, the bounded PriorityBlockingQueue will be used in a ThreadPoolExecutor.

NB: By bounded I don’t want to throw Exception if that happens, I want to put the object in the queue and then cut it based on its priority value. Is there any good way to do this cut thingie?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:43:02+00:00Added an answer on May 13, 2026 at 9:43 pm

    I actually wouldn’t subclass it. While I can’t put together example code right now, I’d suggest a version of the decorator pattern.

    Create a new class and implement the interfaces implemented by your class of interest: PriorityBlockingQueue. I’ve found the following interfaces used by this class:

    Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>
    

    In the constructor for a class, accept a PriorityBlockingQueue as a constructor parameter.

    Then implement all the methods required by the interfaces via the instances of the PriorityblockingQueue. Add any code required to make it Bounded. This is a fairly standard implementation of a Decorator pattern.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use a PriorityBlockingQueue to maintain a list of objects whose order is dictated
I am making a client-server Java app that is going to be MV(C, P)
Suppose I create a thread safe object: PriorityBlockingQueue<Object> safeQueue = new PriorityBlockingQueue<Object>(); If I
I currently have a concurrent queue implementation that uses a BlockingQueue as the data
Please assume the following: public static void main(String[] args) { ThreadPoolExecutor pool = new
I'm trying to make an ThreadPoolExecutor with priority. So I define a private static
This issue has come up in a distributed-multithreaded application I'm developing, where threads can
I want to augment or lower the priority of items in a PriorityQueue :
I'm sure this is a basic OOP question -- I'm designing a message-passing system
I have written a GUI for operating a card reader - mainly consisting of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.