KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > EDU > oswego > cs > dl > util > concurrent > DefaultChannelCapacity


1 /*
2   File: DefaultChannelCapacity.java
3
4   Originally written by Doug Lea and released into the public domain.
5   This may be used for any purposes whatsoever without acknowledgment.
6   Thanks for the assistance and support of Sun Microsystems Labs,
7   and everyone contributing, testing, and using this code.
8
9   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_ =
31     new SynchronizedInt(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) throw new IllegalArgumentException JavaDoc();
41     defaultCapacity_.set(capacity);
42   }
43
44   /**
45    * Get the default capacity used in
46    * default (no-argument) constructor for BoundedChannels
47    * that otherwise require a capacity argument.
48    * Initial value is <code>INITIAL_DEFAULT_CAPACITY</code>
49    * @see #INITIAL_DEFAULT_CAPACITY
50    */

51   public static int get() {
52     return defaultCapacity_.get();
53   }
54 }
55
Popular Tags