At 11:25  16/3/01 -0800, Ram C wrote:
>---- Peter Donald <[EMAIL PROTECTED]> wrote:
>> At 11:26  15/3/01 -0800, Ram C wrote:
>> >Should the methods, pop(), insert(),peek() in BinaryHeap be syncronized
>> >? 
>> 
>> Possibly - though I would prefer if they were unsynchronized by default
>> but
>> you could make them synchronized like
>> 
>> PriorityQueue pq = new SynchronizedPriorityQueue( new BinaryHeap()
>> );
>
>I can create a new SynchronizedPriorityQueue(or should it be
SyncronizedBinaryHeap
>???) which implements PriorityQueue, and calls all the BinaryHeap methods
>using syncronized wrapper methods.

I think SynchronizedPriorityQueue because if/when I actually implement
another type of priority queue this will still work (then again that
particular job has been on TODO list for at least a year 8-]).

>> or perhaps
>> 
>> PriorityQueue pq = AvalonCollections.synchronize( new BinaryHeap()
>> );
>> 
>
>I don't understand this...How would this synchronization work? I can
>see you want to create a static method 'synchronize' in AvalonCollections.
>sorry i'm new to these kind of stuff...so please pardon my ignorance.

Its basically a pattern introduced in Java2 collections. ie You can go

List list = Collections.synchronizedList( new LinkedList() );
Map map = Collections.synchronizedMap( new HashMap() );

Which just synchronizes all the methods (presumably by a wrapper like
described above).

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to