Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util
Class ThreadGate.ThreadLocalCounter

    java.lang.Object
      java.lang.ThreadLocal
          com.tangosol.util.ThreadGate.ThreadLocalCounter

Enclosing class:
  ThreadGate

    public static class ThreadGate.ThreadLocalCounter

extends java.lang.ThreadLocal

Specialization of `ThreadLocalObject` that can be used for efficient thread local long counters.

This class associates a single `Long` value with the current thread. The `Long` value may be retrieved, set, removed, incremented, or decremented.

Author:
  jh 2004.12.03

Constructor Summary
`ThreadGate.ThreadLocalCounter()` Create a new `ThreadLocalCounter` with an initial `Long` value of zero.

Method Summary
`long` | `decrement()` Decrement the `Long` value of the `ThreadLocalCounter` for the current thread by one.
`long` | `getCount()` Obtain the long value of the `ThreadLocalCounter` for the current thread.
`long` | `increment()` Increment the `Long` value of the `ThreadLocalCounter` for the current thread by one.
`void` | `set(java.lang.Object oValue)` Set the `Long` value of the `ThreadLocalCounter` for the current thread.
`void` | `setCount(long c)` Set the long value of the `ThreadLocalCounter` for the current thread.

Methods inherited from class java.lang.ThreadLocal
`get, initialValue, remove`

Constructor Detail

### ThreadGate.ThreadLocalCounter

    public ThreadGate.ThreadLocalCounter()

  Create a new `ThreadLocalCounter` with an initial `Long` value of zero.

Method Detail

### getCount

    public long getCount()

  Obtain the long value of the `ThreadLocalCounter` for the current thread.

  Returns:
    the count for the current thread

### setCount

    public void setCount(long c)

  Set the long value of the `ThreadLocalCounter` for the current thread.

  Parameters:
    `c` - the long counter value for the current thread
  See Also:
    `getCount()`, `set(Object)`

### increment

    public long increment()

  Increment the `Long` value of the `ThreadLocalCounter` for the current thread by one. If the `ThreadLocalCounter` has been removed or its value is null, 1 is returned.

  Returns:
    the new `Long` value for the current thread or 1 if the `ThreadLocalCounter` has been removed or its value is null
  See Also:
    `decrement()`

### decrement

    public long decrement()

  Decrement the `Long` value of the `ThreadLocalCounter` for the current thread by one. If the `ThreadLocalCounter` has been removed or its value is null, -1 is returned.

  Returns:
    the new `Long` value for the current thread or -1 if the `ThreadLocalCounter` has been removed or its value is null
  See Also:
    `increment()`

### set

    public void set(java.lang.Object oValue)

  Set the `Long` value of the `ThreadLocalCounter` for the current thread.

  Overrides:
    `set` in class `java.lang.ThreadLocal`
  Parameters:
    `oValue` - the `Long` value for the current thread
  Throws:
    `java.lang.ClassCastException` - if the supplied value is non-null and not an instance of `Long`

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.