Re: Somewhere in this constructor of PriorityBlockingQueue is hard to understand

Liu via Concurrency-interest <[email protected]> Tue, 4 Aug 2020 23:55:55 +0800 (GMT+08:00)
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <[email protected]>
Thanks for your answer!


About first question, if you say so, then maybe Instanceof allows subclasses which could be coded to break the assumption that items are not null.
I mean, only when "pq.getClass() == PriorityBlockingQueue.class" Expression holds, then you could do "screen = false".
Am i wrong?


> If the size is greater than one and there is no comparator heapify() will catch the null element.


About Third question, I think heapify() could not catch the null element that is at the back of array.
Because heapify() from last-non-leaf-node index to zero to invoke siftDownComparable(), 
so heapify() couldn't Traverse every node.
And siftDownComparable() has a "while (k < half)", which half means first-leaf-node index,
so when k become a leaf-node index, the siftDown will stop too.
To sum up, heapify() could not catch the null element that is at the back of array.


--------------------------------------------------------------------------------
Regards
Liu

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest