lowLatency
lowLatency

Reputation: 5664

vector usage in non-multithreaded application

Vector vs Arraylist (in non-multithreading environment) – in which requirements we will use Vector (rather than ArrayList)
One I know : if the size of the collection has to be increased dynamically and very frequently as vector size increases by 100% and ArrayList 50%

Upvotes: 0

Views: 91

Answers (2)

dash1e
dash1e

Reputation: 7807

In a single thread environment never user Vector. Its methods are "synchronized" and this makes it slow, very slow against ArrayList.

So event if the ensureCapacity behavior is different, and Vector increase the size by 2, the cost of every single operation cannot be compared with the cost of the ArrayList operations, that are more fast.

Upvotes: 0

Samir Mangroliya
Samir Mangroliya

Reputation: 40416

I think you should not use vector because you have to syncronized(also non-threaded environment) ,So Use ArrayList

Vector is syncronized each operation ,do not whole operation and .....and its also deprecated... Why is Java Vector class considered obsolete or deprecated?

Upvotes: 1

Related Questions