permaculture playing cards*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Vector -- how do i use it??" Watch "Vector -- how do i use it??" New topic
Author

Vector -- how do i use it??

Derick Potgieter
Greenhorn

Joined: Feb 19, 2004
Posts: 13
Hi,

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.

Thanks
Derick
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: 1064
Derick,
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.

lockedList.add(recNo)

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

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??
 
Similar Threads
SecurityException
Locking
my question about LockManager.java
UrlyBird 1.3.2 locking with no cookie
Question of unlock() method