01: /* ****************************************************************************
02: * ObjectCounter.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
10: package org.openlaszlo.utils;
11:
12: /**
13: * Thread safe counter object.
14: */
15: public class ThreadSafeCounter {
16: int mCount = 0;
17:
18: synchronized public void increment() {
19: ++mCount;
20: }
21:
22: synchronized public void decrement() {
23: --mCount;
24: }
25:
26: synchronized public void decrement(int n) {
27: mCount -= n;
28: }
29:
30: synchronized public int getCount() {
31: return mCount;
32: }
33: }
|