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 9088411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:54:13+00:00 2026-06-16T21:54:13+00:00

I implemented a producer-consumer pattern with Java’s LinkedBlockingDeque, but I have hit a problem,

  • 0

I implemented a producer-consumer pattern with Java’s LinkedBlockingDeque, but I have hit a problem, that I sometimes want to move an item (which is alread somewhere in the queue) to the front of the queue, so it is processed sooner. I never know which of the already enqueued items would be good to move to the front. So I would like the LinkedBlockingDeque to be replaced by something, where I can reorder items. I have one producer and 2-4 consumers (custom Thread implementation) and I am on Android platform. How can I do this? Some blocking double connected linked list?

  • 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-06-16T21:54:14+00:00Added an answer on June 16, 2026 at 9:54 pm

    From my comment:

    You could use remove(Object o) to retrieve the object and remove it from the queue, then use addFirst(Object o) to add it to the front of the queue. This will have the effect of prioritising this object.

    You use the iterator to check what object are inside the Deque. However be very careful of ConcurrentModificationException as they could be raised if you are accessing the Collection in one thread and modifying it in another, however if you are using a blockingQueue this shouldn’t be an issue.

    From BlockingQueue Javadoc:

    BlockingQueue implementations are thread-safe. All queuing methods
    achieve their effects atomically using internal locks or other forms
    of concurrency control. However, the bulk Collection operations
    addAll, containsAll, retainAll and removeAll are not necessarily
    performed atomically unless specified otherwise in an implementation.
    So it is possible, for example, for addAll(c) to fail (throwing an
    exception) after adding only some of the elements in c.

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

Sidebar

Related Questions

I have implemented a java version of Producer && Consumer pattern in java and
I'm thinking how to implement the producer/consumer pattern in Java. Assume that I have
My understanding of a Producer-Consumer pattern is that it could be implemented using a
I've implemented a Producer/Consumer pattern using a BlockingCollection however it doesn't seem to be
I've implemented something similar to consumer-producer problem using a unbounded linked blocking queue. I
I'm using a BlockingCollection to implement a producer/consumer pattern. I have an asynchronous loop
Classic producer-consumer-problem. I have x app servers which write records in a DB table
I have Implemented a semaphore class for producer and consumer. It is working fine,
I implemented Producer/Consumer pattern with BlockingCollection for my experiment. PerformanceCounter c = null; void
I have implemented a basic threaded producer-consumer (thread 1 = producer, thread 2 =

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.