KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > orbutil > concurrent > SyncUtil


1 /*
2  * @(#)SyncUtil.java 1.3 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.orbutil.concurrent;
9
10 import com.sun.corba.se.impl.orbutil.concurrent.Sync ;
11
12 public class SyncUtil {
13     private SyncUtil() {}
14
15     /** Method to acquire a Sync without ever throwing an
16     * InterruptedException. Useful when a mutex is being
17     * used in place of Java synchronization.
18     */

19     public static void acquire( Sync sync )
20     {
21     boolean held = false ;
22     while (!held) {
23         try {
24         sync.acquire() ;
25         held = true ;
26         } catch (InterruptedException JavaDoc exc) {
27         held = false ;
28         }
29     }
30     }
31 }
32
Popular Tags