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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:33:44+00:00 2026-06-02T16:33:44+00:00

When we use one of the inbuilt queues like ConcurrentLinkedQueue or even some BlockingQueue,

  • 0

When we use one of the inbuilt queues like ConcurrentLinkedQueue or even some BlockingQueue, single calls are atomic and guaranteed to be thread safe.
But when of the 5 calls to the API, 4 calls are single, but one call is of the form:

if(some condition)
{
    queue.call();
}

This call needs to be in a synchronized block since this operations is non atomic.
But doesn’t introducing this call also means that all access to this queue, whether read or write should be synchronized from now on?

If yes, can I assume that once a single non atomic call creeps in the code, which is very likely, then all access to the fancy queue will have to be manually synchronized?

  • 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-02T16:33:46+00:00Added an answer on June 2, 2026 at 4:33 pm

    ConcurrentLinkedQueue doesn’t make the quite the same atomic guarantees that you assume. From the javadoc:

    Memory consistency effects: As with other concurrent collections,
    actions in a thread prior to placing an object into a
    ConcurrentLinkedQueue happen-before actions subsequent to the access
    or removal of that element from the ConcurrentLinkedQueue in another
    thread.

    It’s not the same as wrapping a LinkedList or something in a Collections.synchronizedList; different threads might see different answers to size(), for example, because it doesn’t lock the collection.

    Based on your comment you can probably replace the if statement with a single call to Queue‘s poll and check if the retrieved element is null.

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

Sidebar

Related Questions

can any one help me to use the mysql inbuilt function in cakePHP?????
I'm trying to use one single image sprite for typical male / female radio
we use One-Time initialization for pthreads like this: /* define a statically initialized pthread_once_t
Most of the developer use one of the core .NET language ( Like c#,
I want to use one thread to get fields of packets by using tshark
The use case is that I use one development machine for different source trees.
I need to use one of the resourceful controllers plugins - resources_controller/ resource_controller/make_resourceful as
Suppose both parent and child use one pipe for writing and reading means when
Is there a way to use one CASE statement and return 2 different values?
Is there a performance hit if you use one data type for your primary

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.