[concurrency-interest] Language extensions forjava.util.concurrent?

Dawid Kurzyniec dawidk at mathcs.emory.edu
Thu Nov 10 15:49:42 EST 2005


Elias Ross wrote:

>Too bad Java doesn't have the C# keyword "using", it would be nice to be
>able to write
>
>     void around() {
>        using (rt) {
>          proceed();
>        }
>     }
>
>It's too easy to accidentally write:
>
>     void around() {
>        try {
>          rl.lock();
>          proceed();
>        } finally {
>          rl.unlock();
>        }
>     }
>
>  
>
 From this example, "using" seems to me to be just like "synchronized".  
(I don't know C#). The problem with this syntax is that it does not 
allow using tryLock(...), and lockInterruptibly(). That's why I would 
opt for lock.lock() { ... }

Regards,
Dawid



More information about the Concurrency-interest mailing list