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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:47:18+00:00 2026-06-18T08:47:18+00:00

Vectors contain synchronized methods, and ArrayLists do not. These synchronized methods help prevent data

  • 0

Vectors contain synchronized methods, and ArrayLists do not. These synchronized methods help prevent data corruption when the data is accessed and modified by >1 thread.

Can someone explain this in more detail for me? What does it mean that Vectors contain synchronized methods? Do the methods contain internal locks that control the locking and unlocking of the data for multiple thread access? Can someone provide some examples of where using a vector (vs. ArrayList) could prevent data corruption and shed some more light on the issue or Data Structures and synchronization issues?

Thanks for your time and help .

  • 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-18T08:47:19+00:00Added an answer on June 18, 2026 at 8:47 am

    What does it mean that Vectors contain synchronized methods?

    The methods have been marked as synchronized.

    Do the methods contain internal locks that control the locking and unlocking of the data for multiple thread access?

    No, despite the keyword being on the method, it is the object which is locked, not the method. There is no way to lock a method as such.

    Can someone provide some examples of where using a vector (vs. ArrayList) could prevent data corruption and shed some more light on the issue or Data Structures and synchronization issues?

    There are many examples. The simplest is incrementing a number. Say you have two threads incrementing a number (e.g. the size of the collection) Without synchronization you can have.

    Thread1: read size e.g. 0
    Thread1: increment size
    Thread1: write size e.g. 1
    Thread2: read size e.g. 1
    Thread2: increment size
    Thread2: write size e.g. 2
    

    however as threads can perform actions in any order (as this is the whole point of threads) you can also have

    Thread1: read size e.g. 0
    Thread2: read size e.g. 0
    Thread1: increment size
    Thread2: increment size
    Thread1: write size e.g. 1
    Thread2: write size e.g. 1
    

    So even though two threads have incremented the counter, it is incorrect because their actions where not co-ordinated. This is what synchronization does for you.

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

Sidebar

Related Questions

I have a function that currently accepts 2 vectors that can contain any plain
I want a std::vector to contain some functions, and that more functions can be
I am using a cell array to contain 1x2 vectors of grid locations in
I've got a two vectors in class A that contain other class objects B
Suppose I have two vectors of same dimensions: x <-c(0.49534,0.80796,0.93970,0.99998) count <-c(0,33,0,4) How can
I am trying to multiply two vectors in Prolog but, if those vectors contain
I have two vectors: a vector and index vector. How can I make the
I have four std::vector containers that all might (or might not) contain elements. I
After using sapply(data, unlist), I have what I think is a matrix of vectors
for google and stackoverflow search could not help me I have no choice but

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.