[concurrency-interest] Language extensions for java.util.concurrent?

Elias Ross eross at m-Qube.com
Thu Nov 10 15:43:47 EST 2005


On Thu, 2005-11-10 at 14:15 -0500, Jeremy Manson wrote:

>      public ReentrantLock rl = new ReentrantLock();
> 
>      void around() {
>         rl.lock();
>         try {
>           proceed();
>         } finally {
>           rl.unlock();
>         }
>      }

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();
        }
     }




More information about the Concurrency-interest mailing list