[concurrency-interest] Fwd: ReadWriteLocks and Conditions

Tim Peierls tim at peierls.net
Tue Feb 6 17:42:59 EST 2007


LendableReference is essentially a resource pool of size 1. Other folks have
done a lot of work on the general case -- why not take advantage of that?

Or if you really want to roll your own, consider using Semaphores, as
described in section 5.5.3 of Java Concurrency in Practice.

--tim


On 2/6/07, Peter Veentjer <alarmnummer at gmail.com> wrote:
>
> Example usage:
>
> while(true){
>         Runnable task = lendableRef.take();
>         try{
>                 task.execute();
>         }finally{
>                 lendableRef.takeBack(task);
>         }
> }
>
> By placing a Runnable in the lendableRef, the task is being executed.
> By removing the Runnable from the lendableRef (so setting a null
> value) the take blocks.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20070206/6f768dfa/attachment.html 


More information about the Concurrency-interest mailing list