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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:27:40+00:00 2026-06-08T07:27:40+00:00

After stuff like Hashtable and Vector where discouraged, and when the Collections synchronized wrappers

  • 0

After stuff like Hashtable and Vector where discouraged, and when the Collections synchronized wrappers came up, I thought synchronization would be handled more efficiently. Now that I looked into the code, I’m surprised that it really is just wrapping the collections with synchronization blocks.

Why are ReadWriteLocks not included into, for example, SynchronizedMap in Collections? Is there some efficiency consideration that doesn’t make it worth it?

  • 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-08T07:27:44+00:00Added an answer on June 8, 2026 at 7:27 am

    Read-write locks are part of performance optimization, which means it can allow greater concurrency in certain situations. The necessary condition is, that they are applied on data structures which are read most of the time, but not modified.

    Under other conditions they perform slightly worse than exclusive locks, which comes natural since they have a greater complexity.

    It is most efficient, if the locks of a read-write lock are held typically for a moderately long time and only few modifications on the guarded resources.

    Hence, whether read-write locks are better than exclusive locks depends on the use case. Eventually you have to measure with profiling which locks perform better.

    Taking this into account it seems fitting to choose an exclusive lock for Collections.synchronizedMap addressing the general use case instead of the special case with mostly-readers.

    Further Links

    • Starvation with ReadWriteLocks
    • Refactoring Java Programs for Flexible Locking

      They wrote a tool which converts locks in a Java application automatically into ReentrantLocks and ReadWriteLocks where appropriate. For measuring purposes they have also provided some interesting benchmarking results:

    enter image description here

    […] However, in a configuration where write operations were more
    prevalent, the version with synchronized blocks was 50% faster than
    one based on read-write locks with the Sun 1.6.0_07 JVM (14% faster
    with the Sun 1.5.0_15 JVM).

    In a low-contention case with just 1
    reader and 1 writer, the performance differences were less extreme,
    and each of the three types of locks yielded the fastest version on at
    least one machine/VM configuration (e.g., note that ReentrantLocks were fastest on the 2-core machine with the Sun 1.5.0_15 JVM).

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

Sidebar

Related Questions

Say I have a connection to a database. After reading some stuff I want
I have an activity with some views, after doing some stuff I want to
I've noticed, that every time I compact my CouchDB instance after inserting some stuff,
After following this MVC 4 tutorial series I was trying some of the stuff
After googeling for ages, and reading some stuff about async task in books. I
I'm seeing some weird stuff happening in my app. After coming back to the
I am looking for where I should save my app stuff, and after a
We have an API built on Rails, and processing some stuff with resque. After
I have hard time with kohana sessions, i would like to store my sessions
My site makes use of ajax heavily for stuff like editing user details. I

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.