• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Vector -- how do i use it??

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic