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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:09:08+00:00 2026-06-14T10:09:08+00:00

My code has a data structure shared between many threads, but I am using

  • 0

My code has a data structure shared between many threads, but I am using LinkedBlockingQueue, so would synchronized be necessary at all in the following code?

public synchronized String getDirectory(){
    return directoryArray.poll();
}
  • 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-14T10:09:10+00:00Added an answer on June 14, 2026 at 10:09 am

    I dont think you required extra synchronization. According to docs – link

    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

Perl threads do not support sharing filehandles. All the elements of a shared data
I'm working in a code that has a data structure like this: type TData1
The data structure is as follows: A house has many rooms. Each room has
I need a data structure in which each element has a specific index but
I am using EclipseLink MOXy and have a data structure that has child elements
I need to ship some Java code that has an associated set of data.
Has anybody ever successfully written code to extract data from a SharePoint 2007 list
Google has an example on analytic data for mobile devices. The code is provided
I have been looking into using Boost.Interprocess to create a disk-backed data structure. The
Is there any data structure in C# that is like a dictionary but that

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.