Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector -- how do i use it??

 
Derick Potgieter
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic