jQuery in Action, 3rd edition
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Vector -- how do i use it?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Vector -- how do i use it??" Watch "Vector -- how do i use it??" New topic

Vector -- how do i use it??

Derick Potgieter

Joined: Feb 19, 2004
Posts: 13

I`m busy with my lock method.

but my problem is in my unlock method nl.

how can i remove the recno that i locked from the vector, i`m specifying
the location to remove, but i only have the record no to work with??

Any suggestions?? the reason for the vector is because it is thread safe, and i`m syncronizing on it.

Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
Hi Derick

Why do you need lockedList? You store locked record number in HashMap, why to duplicate it in Vector?

You may make HashMap as static instance, and I see no problems with synchronization here.
[ June 02, 2004: Message edited by: Denis Spirin ]

Regards<br /> <br />Ph.D.<br />SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD 2
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Vector also has another remove method. Did you try that?

Object remove(int index)
boolean remove(Object o)

You can remove the same way you removed the rec number object from the map.
Moreover, you can only add objects to Vector. I think you are trying to add
a primitive type to the Vector in your locking method.


Just curious, why are you using 2 collection classes for your locking design?
Dmitry Gavrilov

Joined: Jun 04, 2004
Posts: 1
Hi Derick
I think that You can do so...

But I think that the better decision is to create a LockManager.class.
[ June 04, 2004: Message edited by: Dmitry Gavrilov ]
Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
In fact, if you access collection from sync block, you dont need to care about if this collection is sync or not.
I agree. Here's the link: http://aspose.com/file-tools
subject: Vector -- how do i use it??
It's not a secret anymore!