01: /*
02: File: DefaultChannelCapacity.java
03:
04: Originally written by Doug Lea and released into the public domain.
05: This may be used for any purposes whatsoever without acknowledgment.
06: Thanks for the assistance and support of Sun Microsystems Labs,
07: and everyone contributing, testing, and using this code.
08:
09: History:
10: Date Who What
11: 11Jun1998 dl Create public version
12: */
13:
14: package EDU.oswego.cs.dl.util.concurrent;
15:
16: /**
17: * A utility class to set the default capacity of
18: * BoundedChannel
19: * implementations that otherwise require a capacity argument
20: * @see BoundedChannel
21: * [<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>] <p>
22: **/
23:
24: public class DefaultChannelCapacity {
25:
26: /** The initial value of the default capacity is 1024 **/
27: public static final int INITIAL_DEFAULT_CAPACITY = 1024;
28:
29: /** the current default capacity **/
30: private static final SynchronizedInt defaultCapacity_ = new SynchronizedInt(
31: INITIAL_DEFAULT_CAPACITY);
32:
33: /**
34: * Set the default capacity used in
35: * default (no-argument) constructor for BoundedChannels
36: * that otherwise require a capacity argument.
37: * @exception IllegalArgumentException if capacity less or equal to zero
38: */
39: public static void set(int capacity) {
40: if (capacity <= 0)
41: throw new IllegalArgumentException();
42: defaultCapacity_.set(capacity);
43: }
44:
45: /**
46: * Get the default capacity used in
47: * default (no-argument) constructor for BoundedChannels
48: * that otherwise require a capacity argument.
49: * Initial value is <code>INITIAL_DEFAULT_CAPACITY</code>
50: * @see #INITIAL_DEFAULT_CAPACITY
51: */
52: public static int get() {
53: return defaultCapacity_.get();
54: }
55: }
|