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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:35:25+00:00 2026-05-11T02:35:25+00:00

I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here’s the

  • 0

I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here’s the blurb from the javadoc for the class.

An unbounded thread-safe queue based on linked nodes. A ConcurrentLinkedQueue is an appropriate choice when many threads will share access to a common collection. This queue does not permit null elements.

Now imagine I have 1000 concurrent requests on the servlet, and each thread will need to enque an object into the ConcurrentLinkedQueue. From the description, should I conclude that it will have no problems handling the load ? The guarantee that I will need is that:

  1. I automatically receive the thread-safe guarantee without needing to do my own synchronization.
  2. I will not lose any requests if the traffic load goes beyond 1000 concurrent request.

Thanks

  • 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. 2026-05-11T02:35:25+00:00Added an answer on May 11, 2026 at 2:35 am

    You’re essentially asking three different questions (two of them explicitly and one implicitly.) Here they are, with my answers:

    1. Do I need to do my own synchronization if I use java.util.ConcurrentLinkedQueue?

    Atomic operations on the concurrent collections are synchronized for you. In other words, each individual call to the queue is guaranteed thread-safe without any action on your part. What is not guaranteed thread-safe are any operations you perform on the collection that are non-atomic.

    For example, this is threadsafe without any action on your part:

    queue.add(obj); 

    or

    queue.poll(obj); 

    However; non-atomic calls to the queue are not automatically thread-safe. For example, the following operations are not automatically threadsafe:

    if(!queue.isEmpty()) {    queue.poll(obj); } 

    That last one is not threadsafe, as it is very possible that between the time isEmpty is called and the time poll is called, other threads will have added or removed items from the queue. The threadsafe way to perform this is like this:

    synchronized(queue) {     if(!queue.isEmpty()) {        queue.poll(obj);     } } 

    Again…atomic calls to the queue are automatically thread-safe. Non-atomic calls are not.

    2. Am I guaranteed not to lose calls to java.util.ConcurrentLinkedQueue if there are 1000 simultaneous requests?

    Because this is an unbounded implementation you are guaranteed that no matter how many simultaneous requests to make, the queue will not lose those requests (because of the queue’s concurrency…you might run out of memory or some such…but the queue implementation itself will not be your limiting factor.) In a web application, there are other opportunities to ‘lose’ requests, but the synchronization (or lack thereof) of the queue won’t be your cause.

    3. Will the java.util.ConcurrentLinkedQueue perform well enough?

    Typically, we talk about ‘correctness’ when we talk about concurrency. What I mean, is that Concurrent classes guarantee that they are thread-safe (or robust against dead-lock, starvation, etc.) When we talk about that, we aren’t making any guarantees about performance (how fast calls to the collection are) – we are only guaranteeing that they are ‘correct.’

    However; the ConcurrentLinkedQueue is a ‘wait-free’ implementation, so this is probably as performant as you can get. The only way to guarantee load performance of your servlet (including the use of the concurrent classes) is to test it under load.

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

Sidebar

Ask A Question

Stats

  • Questions 60k
  • Answers 60k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Are you closing the response stream and disposing of the… May 11, 2026 at 9:31 am
  • added an answer A few ways you could achieve this: 1. Do the… May 11, 2026 at 9:31 am
  • added an answer Mono 2.4 will ship with NUnit 2.4.8, and has been… May 11, 2026 at 9:31 am

Related Questions

I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the
I want to use the java.util.Preferences API but I don't want my program to
I'd like to use regex with Java. What I want to do is find
I found this open-source library that I want to use in my Java application.
I want to use JOGL (for Clojure, not Java). There seems to be quite
I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom
I want to use Powershell to write some utilities, leveraging our own .NET components
I want to use the functions exposed under the OpenGL extensions. I'm on Windows,
I want to use the Publish.GacRemove function to remove an assembly from GAC. However,
I want to use the MultipleLookupField control in a web page that will run

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.