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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:03:59+00:00 2026-05-18T01:03:59+00:00

the method java.util.concurrent.BlockingQueue.add(E e)’s JavaDoc reads: boolean add(E e) Inserts the specified element into

  • 0

the method java.util.concurrent.BlockingQueue.add(E e)’s JavaDoc reads:

boolean add(E e)

Inserts the specified element into
this queue if it is possible to do so
immediately without violating capacity
restrictions, returning true upon
success and throwing an
IllegalStateException if no space is
currently available. When using a
capacity-restricted queue, it is
generally preferable to use offer.

My question is: will it ever return false? if not, why does this method return a boolean?
It seems weird to me. What is the design decision behind this?

Thanks for your knowledge!
Manuel

  • 1 1 Answer
  • 1 View
  • 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-18T01:04:00+00:00Added an answer on May 18, 2026 at 1:04 am

    It follows the contract of Collection.add(E e) (since BlockingQueue is a subtype of Collection):

    If a collection refuses to add a
    particular element for any reason
    other than that it already contains
    the element, it must throw an
    exception (rather than returning
    false). This preserves the invariant
    that a collection always contains the
    specified element after this call
    returns.

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

Sidebar

Related Questions

does anyone know if the following java Method in the java.util.concurrent Package ScheduledExecutorService.html#scheduleAtFixedRate() absolutely
I'm experimenting Java Multi-Threading using synchronization on method comparing with Atomic variables (java.util.concurrent.atomic package).
Is there a way to convert milliseconds to minutes using java.util.concurrent.TimeUnit? This answer seems
I am new to java.util.concurrent package and wrote a simple method which fetches some
I create a java.util.concurrent.locks.ReentrantReadWriteLock using new java.util.concurrent.locks.ReentrantReadWriteLock().readLock() and then I pass to a method
Exception in thread Thread-8 java.lang.StackOverflowError at sun.misc.Unsafe.compareAndSwapLong(Native Method) at java.util.concurrent.atomic.AtomicLong.compareAndSet(Unknown Source) at java.util.Random.next(Unknown Source)
The next method of java.util.Random , when I view source in Eclipse, is essentially:
The implementation of the addAll method in java.util.Collections simply loops through the source collection
The java.util.Date toString() method displays the date in the local time zone. There are
The Timer ( java.util.Timer ) doc describes the cancel method as one that affects

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.