Just pondering if there's a use case for weak or soft references in a blocking 
queue.  I was writing a unit test for it today.

One use case might be around cancelled future tasks with an executor, you just 
null out any strong references, if it hasn't yet executed it probably won't.  
Eg future has timed out, null out reference and it is removed from the queue by 
garbage collection.  This might help to keep a queue small when there are a 
large number of tasks being cancelled before they execute, rather than 
occupying memory in the queue between other tasks awaiting execution.

The other case might be an unbounded queue, with a single thread taking, it 
blocks waiting for data, instead of the queue causing a memory explosion when 
it can't handle the data given to it , it just starts dropping objects, a bit 
like a network reciever.  The sender can retry later. 

Cheers,

Peter.

Reply via email to