Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


com.tangosol.util
Class ThreadGate.ThreadLocalCounter

java.lang.Object
  extended by java.lang.ThreadLocal
      extended by 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; coh 2010.08.13

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 increment()
          Increment the Long value of the ThreadLocalCounter for the current thread by one.
protected  java.lang.Long initialValue()
          

 

Methods inherited from class java.lang.ThreadLocal
get, remove, set

 

Constructor Detail

ThreadGate.ThreadLocalCounter

public ThreadGate.ThreadLocalCounter()
Create a new ThreadLocalCounter with an initial Long value of zero.

Method Detail

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()

initialValue

protected java.lang.Long initialValue()
Overrides:
initialValue in class java.lang.ThreadLocal

Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.