Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/ExclusiveExec.java @ 806:2cea76f1112e
Added Javadoc in utils package.
gnv-artifacts/trunk@888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 08 Apr 2010 13:10:39 +0000 |
parents | c4156275c1e1 |
children | 22c18083225e |
comparison
equal
deleted
inserted
replaced
805:bb7afd783321 | 806:2cea76f1112e |
---|---|
14 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | 14 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
16 */ | 16 */ |
17 public final class ExclusiveExec | 17 public final class ExclusiveExec |
18 { | 18 { |
19 /** | |
20 * The only instance of this singleton. | |
21 */ | |
19 public static final ExclusiveExec INSTANCE = new ExclusiveExec(); | 22 public static final ExclusiveExec INSTANCE = new ExclusiveExec(); |
20 | 23 |
21 private HashMap tokens; | 24 private HashMap tokens; |
22 | 25 |
26 /** | |
27 * This class represents a unique key with a reference counter. | |
28 */ | |
23 public static class UniqueKey { | 29 public static class UniqueKey { |
24 Object key; | 30 Object key; |
25 int [] refs; | 31 int [] refs; |
32 | |
33 /** | |
34 * Constructs a new UniqueKey. | |
35 * | |
36 * @param key The key of this unique key. | |
37 */ | |
26 public UniqueKey(Object key) { | 38 public UniqueKey(Object key) { |
27 this.key = key; | 39 this.key = key; |
28 refs = new int[1]; | 40 refs = new int[1]; |
29 } | 41 } |
30 } | 42 } |
39 /** | 51 /** |
40 * This method serves a {@link UniqueKey} and starts a synchronized code | 52 * This method serves a {@link UniqueKey} and starts a synchronized code |
41 * block. | 53 * block. |
42 * | 54 * |
43 * @param key The key used to identify same threads. | 55 * @param key The key used to identify same threads. |
44 * | |
45 * @return UniqueKey. Use this object to call {@link #release(UniqueKey)} | 56 * @return UniqueKey. Use this object to call {@link #release(UniqueKey)} |
46 * at the end of your code being synchronized. | 57 * at the end of your code being synchronized. |
47 */ | 58 */ |
48 public UniqueKey acquire(Object key) { | 59 public UniqueKey acquire(Object key) { |
49 | 60 |