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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:21:07+00:00 2026-06-09T10:21:07+00:00

I was reading this Stackoverflow thread about using StringBuilder versus StringBuffer. The bottom line

  • 0

I was reading this Stackoverflow thread about using StringBuilder versus StringBuffer.

The bottom line seemed to be that the two collections were the same thing except that a StringBuffer is synchronized, is a thread safe and does a little less well in performance as compared to StringBuilder which are not those things.

Someone brought up how a similar relationship existed between ArrayList and Vector.

Is it a good (safe) rule of thumb to NOT use synchronized collections ( or anything else ) unless I am consciously creating multiple threads?

In other words, I got the message “Use the new StringBuilder wherever possible.”, what I want to know is, how can I be sure it is possible?

Am I safe using non-synchronized collections as long as I don’t create new threads intentionally?

  • 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-09T10:21:08+00:00Added an answer on June 9, 2026 at 10:21 am

    Use unsynchronized things until you’re sure that you need synchronization.

    Part of the issue with e.g. StringBuffer and Vector is that they’re not always synchronized in the right way. For Vector, it’s not always what you need to have every operation be synchronized individually; frequently what you actually want is to synchronize blocks of operations…for which Vector isn’t necessarily any better than ArrayList or a Collections.synchronizedList.

    When you know you’re using concurrency and multiple threads, then work out the details of what synchronization you need, but just swapping StringBuffer in for StringBuilder will only give you a false sense of security — even if you decide to use concurrency later, that’s not necessarily the right kind of concurrency.

    (If you’re not currently using threading, then it’s absolutely fine — even recommended — to find-and-replace StringBuffer to StringBuilder. The above arguments are for the reverse direction.)

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

Sidebar

Related Questions

I was reading this thread/post: https://stackoverflow.com/questions/262298/windows-c-ui-technology and am also wondering about a non .NET
I was reading this thread https://stackoverflow.com/questions/268538/tab-versus-space-indentation-in-c-sharp reagrding Tab versus space indentation. The moral of
I've been reading about this on StackOverflow and facebook doc, yet I dont seem
I was reading this StackOverflow question about eager loading which led me to this
I know from reading this Stackoverflow question that the complier will look at your
I thought this other SO thread would have answered my question (http://stackoverflow.com/questions/4883751/trouble-reading-json-object-in-python), as it
When I was reading this tutorial I noticed the following performance tip about using
I was just reading this thread and it occurred to me that there is
After reading many of the replies to this thread , I see that many
After reading this post on Stackoverflow Google plus popup box when hovering over thumbnail?

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.