KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > core > LockManager


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.core;
12
13 import java.util.Hashtable JavaDoc;
14
15 /**
16  * @author aniefer
17  *
18  */

19 public class LockManager {
20     // lock
21
private final static Object JavaDoc lock = new Object JavaDoc();
22
23     // hashtable of locks
24
private static Hashtable JavaDoc locks = new Hashtable JavaDoc();
25     
26     public static Object JavaDoc getLock(String JavaDoc key) {
27         synchronized (lock) {
28             if (locks.get(key) == null)
29                 locks.put(key, key);
30             return locks.get(key);
31         }
32     }
33     
34     public static void returnLock(String JavaDoc key) {
35         synchronized (lock) {
36             locks.remove(key);
37         }
38     }
39 }
40
Popular Tags