0

Hi,
I am new in java. I have a question for which I am not getting suitable answer.
My question is that why vector is called synchronised?
Can anybody please clarify me why vector is synchronised?

6
Contributors
7
Replies
8
Views
9 Years
Discussion Span
Last Post by Ezzaral
0

may be it is a legacy class. but I was asked both the questions in Interview.
That is why I need to know the answers.

0

If you were asked that in an interview and do not have the answer and cannot figure out how to find that answer, you really should not have the job. A working programmer should know how to find answers to such things on their own through the documentation or other available resources.

I don't say that to be mean. It's just something you need to learn to do if you expect to hold a job programming and the sooner you get used to it the better.

0

◄ why vector is called synchronised?

Because it's methods are synchronized.

◄ why vector is synchronised?

A decision made by the language implementors.

Take a look at the source code of the Vector class and things will become a bit more clear for you. Just don't be attracted by the 'synchronized data structure' thing, hand craft your synchronization code. It would save you a lot of trouble.

0

What this means is, if two threads attempt to access a
Vector it will be synchronized. One thread will have to wait until the
other thread is finished accessing the Vector.

0

when there are some critical business transactions are there in your Application so in such kind of situations Vector is used.refer some other documents for the purpose of Vector.

0

Do not use Vector even if you need a synchronized list. Use Collections.synchronizedList(List) or CopyOnWriteArrayList.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.