RFR [6853696] (ref) ReferenceQueue.remove(timeout) may return null even if timeout has not expired

Mandy Chung mandy.chung at oracle.com
Wed Feb 26 18:43:54 UTC 2014

On 2/25/2014 11:08 PM, Ivan Gerasimov wrote:
>> I missed that you remove the strong reference (line 57).   I think 
>> it's good to hold the strong reference so that 
>> ReferenceQueue.remove(timeout) will timeout and the test can verify 
>> reliably.
> This is an important part.
> If we didn't remove the strong reference then both threads would wait 
> for the specified period of time even without the fix.
> The point is to make both threads wake up from lock.wait(timeout), and 
> we do it by removing the strong reference and forcing it be enqueued

Now it becomes clear what the test does (thanks).  It'd be helpful to 
add some comments.  The test should also verify that only one thread 
gets a non-null reference == weakReference and the other should get a 
null reference in addition to the wait time > TIMEOUT.


More information about the core-libs-dev mailing list