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

  • Home
  • SEARCH
  • 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 6612325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:05:05+00:00 2026-05-25T20:05:05+00:00

I implemented in Java what I called a foldable queue, i.e., a LinkedBlockingQueue used

  • 0

I implemented in Java what I called a “foldable queue”, i.e., a LinkedBlockingQueue used by an ExecutorService. The idea is that each task as a unique id that if is in the queue while another task is submitted via that same id, it is not added to the queue. The Java code looks like this:

public final class FoldablePricingQueue extends LinkedBlockingQueue<Runnable> {
    @Override
    public boolean offer(final Runnable runnable) {
        if (contains(runnable)) {
            return true; // rejected, but true not to throw an exception
        } else {
            return super.offer(runnable);
        }
    }
}

Threads have to be pre-started but this is a minor detail. I have an Abstract class that implements Runnable that takes a unique id… this is the one passed in

I would like to implement the same logic using Scala and Akka (Actors).
I would need to have access to the mailbox, and I think I would need to override the ! method and check the mailbox for the event.. has anyone done this before?

  • 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-25T20:05:06+00:00Added an answer on May 25, 2026 at 8:05 pm

    This is exactly how the Akka mailbox works. The Akka mailbox can only exist once in the task-queue.

    Look at:

    https://github.com/jboner/akka/blob/master/akka-actor/src/main/scala/akka/dispatch/Dispatcher.scala#L143

    https://github.com/jboner/akka/blob/master/akka-actor/src/main/scala/akka/dispatch/Dispatcher.scala#L198

    Very cheaply implemented using an atomic boolean, so no need to traverse the queue.

    Also, by the way, your Queue in Java is broken since it doesn’t override put, add or offer(E, long, TimeUnit).

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

Sidebar

Related Questions

I have a javascript interface implemented in Java that is called by my javascript
Has anyone successfully implemented a Java based solution that uses Microsoft SQL Server 2005
There is a good function that I need, which is implemented in the Java
Its known that Java ArrayList is implemented using arrays and initializes with capacity of
I have a service class implemented in Java 6 / Spring 3 that needs
The Java debugger has a command called 'drop to frame' that takes you back
I've created a simple Java application that each second for for 10 seconds consecutive
I downloaded a program implemented in Java (in this case, http://julian.togelius.com/mariocompetition2009/index.php ). I first
Because of how generics are implemented in Java (eventually compiling down to objects and
I'm currently working with a specialized, interpreted, programming language implemented in Java. As a

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.